How to examine SharedPreferences from adb shell?

前端 未结 8 702
傲寒
傲寒 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:11

    If you'd like to edit Shared Preferences from adb scripts, please see how to get root on Android emulator here. (If using 'adb root' is not enought in your case).

    If you wish to install vi editor/busybox on Android go here. [OPTIONAL]

    To edit a shared preference value, you need to first COPY app's xml file to SDstorage, copy it to your local filesystem, edit and then upload back to the phone.

    adb shell
    su
    cp /data/data/com.your.package.name/shared_prefs/com.your.package.name_preferences.xml /storage/emulated/0/
    adb pull /storage/emulated/0/com.your.package.name_preferences.xml
    nano com.your.package.name_preferences.xml
    adb push com.your.package.name_preferences.xml /storage/emulated/0/com.your.package.name_preferences.xml
    cp /storage/emulated/0/com.your.package.name_preferences.xml /data/data/com.your.package.name/shared_prefs/com.your.package.name_preferences.xml
    

    Don't forget to RESTART the app to see the results.

提交回复
热议问题