How to examine SharedPreferences from adb shell?

前端 未结 8 810
傲寒
傲寒 2021-01-30 10:30

Now that we can Examining sqlite3 Databases from a Remote Shell, is it possible to examine SharedPreferences from adb shell? Since it would be much more convenient to examine an

8条回答
  •  無奈伤痛
    2021-01-30 11:06

    I am using this convenient one-liner to pull, edit in vim, and push shared preferences for an app:

    APP_ID=com.myapp; adb pull /data/data/${APP_ID}/shared_prefs/${APP_ID}_preferences.xml /tmp/${APP_ID}_preferences.xml && vim /tmp/${APP_ID}_preferences.xml && adb push /tmp/${APP_ID}_preferences.xml /data/data/${APP_ID}/shared_prefs/
    

    Just set APP_ID to your application id.

    Note that this assumes you are using the default file name for shared preferences, as obtained from PreferenceManager.getDefaultSharedPreferences(context). Also, ADB needs to be running in root mode: adb root

提交回复
热议问题