Where are shared preferences stored?

AndroidSharedpreferences

Android Problem Overview


Where in an Eclipse project might one encounter a shared preferences file?

Android Solutions


Solution 1 - Android

SharedPreferences are stored in an xml file in the app data folder, i.e.

/data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PREFS_NAME.xml

or the default preferences at:

/data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PACKAGE_NAME_preferences.xml

SharedPreferences added during runtime are not stored in the Eclipse project.

Note: Accessing /data/data/<package_name> requires superuser privileges

Solution 2 - Android

Preferences can either be set in code or can be found in res/xml/preferences.xml. You can read more about preferences on the Android SDK website.

Solution 3 - Android

Just to save some of you time...

On my Galaxy S v.2.3.3 Shared Preferences are not stored in:/data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PREFS_NAME.xml

but are now located in: /dbdata/databases/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PREFS_NAME.xml

I believe they changed this in 2.3

Solution 4 - Android

I just tried to get path of shared preferences below like this.This is work for me.

File f = getDatabasePath("MyPrefsFile.xml");

if (f != null)
    Log.i("TAG", f.getAbsolutePath());

Solution 5 - Android

The data is stored on the device, in your application's private data area. It is not in an Eclipse project.

Solution 6 - Android

Shared Preferences are the key/value pairs that we can store. They are internal type of storage which means we do not have to create an external database to store it. To see it go to,

  1. Go to View in the menu bar. Select Tool Windows.
  2. Click on Device File Explorer.
  3. Device File Explorer opens up in the right hand side.
  4. Find the data folder and click on it.
  5. In the data folder, you can select another data folder.
  6. Try to search for your package name in this data folder. Ex: com.example.com
  7. Then Click on shared_prefs and open the .xml file.

Hope this helps!

Solution 7 - Android

Use http://facebook.github.io/stetho/ library to access your app's local storage with chrome inspect tools. You can find sharedPreference file under Local storage -> < your app's package name >

enter image description here

Solution 8 - Android

save in /data/data/your_package_name/shared_prefs/

For see that you can use:

Android Device Monitor

Stetho

Android Debug Database

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionfarm ostrichView Question on Stackoverflow
Solution 1 - AndroidAleadamView Answer on Stackoverflow
Solution 2 - AndroidJasCavView Answer on Stackoverflow
Solution 3 - Androidandroid-overflowView Answer on Stackoverflow
Solution 4 - AndroidRamesh AkulaView Answer on Stackoverflow
Solution 5 - AndroidhackbodView Answer on Stackoverflow
Solution 6 - AndroidChinmai KulkarniView Answer on Stackoverflow
Solution 7 - AndroidHarshit JainView Answer on Stackoverflow
Solution 8 - AndroidRasoul MiriView Answer on Stackoverflow