23

Does somebody knows where the file with the actual stored SharedPreferences is located?

rantravee
  • 7,411
  • 9
  • 35
  • 47

1 Answers1

49

Yes I know.

/data/data/com.your.package/shared_prefs/com.your.package_preferences.xml

So you get there by running in console:

# adb shell
# cd /data/data/com.your.package/shared_prefs/
# ls
Pentium10
  • 204,586
  • 122
  • 423
  • 502
  • 4
    The filename may vary, depending on how the `SharedPreferences` were constructed, but the directory is correct. – CommonsWare Apr 02 '10 at 12:53
  • If i want to see the Data that are stored in to that XML file then ? Please reply on this as i realy need it. . . – Shreyash Mahajan Sep 12 '11 at 05:27
  • 2
    To stay at the example here: `cat com.your.package_preferences.xml` But you have to have a rooted phone to be able to read. – Hernd DerBeld Mar 07 '12 at 14:15
  • 1
    any chance to access that on a non rooted phone ? – njzk2 Apr 18 '12 at 15:13
  • 1
    No, you need to root it to circumvent the user based access system, every application has an unique user. If the application in question made the preference-file world-readable, this does not apply and you should be able to cat/read it. – Sveinung Kval Bakken Jun 04 '12 at 16:30
  • 10
    @njzk2: You don't need to root your phone, you can just use the `run-as` utility, e.g. `adb shell run-as com.your.package cat /data/data/com.your.package/shared_prefs/com.adamrosenfield.wordswithcrosses_preferences.xml` – Adam Rosenfield Nov 04 '13 at 05:22
  • This answer is outdated already for Android 6. E.g. on my device shared preferences are located inside /data/user/0/... Correct way to find location of the shared preferences folder is here: http://stackoverflow.com/a/14651771/297710 File prefsdir = new File(getApplicationInfo().dataDir,"shared_prefs"); ... – yvolk May 15 '16 at 14:55