How can I view the shared preferences file using Android Studio?

前端 未结 14 1072
甜味超标
甜味超标 2020-11-27 11:33

I\'m using shared preferences to store certain values for my app. I would like to see the file where the info is actually stored on my phone. I found many ways to do this on

14条回答
  •  时光说笑
    2020-11-27 12:16

    From Android Studio , start Android Device Monitor, go to File Explorer, and browse "/data/data/< name of your package >/shared_prefs/". You will find the XML there... and also you can copy it for inspection.

    If you have a non-rooted device it's not possible to do that directly from Android Studio. However, you can access the file with adb shell as long as your application is the debug version.

    adb shell
    run-as your.app.id
    chmod 777 shared_prefs/your.app.id_preferences.xml
    exit # return to default user
    cp /data/data/your.app.id/shared_prefs/your.app.id_preferences.xml /sdcard
    

    After that you can pull the file from /sdcard directory with adb.

提交回复
热议问题