Reference

SharedPreferences

SharedPreferences is an Android API for storing small amounts of key-value data (settings, flags, tokens) in a private XML file inside the app's data directory, persisted across launches without a database.

Android developmentAndroid

SharedPreferences

Also known as: shared preferences android, app prefs storage, android sharedpreferences, preferences XML

SharedPreferences is an Android API for storing small amounts of key-value data (settings, flags, tokens) in a private XML file inside the app's data directory, persisted across launches without a database.

  • Stores key-value primitives in a private XML file under /data/data/<package>/shared_prefs/.
  • Counts as app data, so it survives a cache clear but is wiped by Clear storage or uninstall.
  • Jetpack DataStore is the recommended modern replacement for larger or async data.

What it stores and where

SharedPreferences holds primitives — booleans, ints, longs, floats, and strings — keyed by name. It is meant for lightweight app state like user settings, onboarding flags, or feature toggles, not for large or relational data. You read values directly and write through an Editor with apply() (async) or commit() (synchronous).

Each preferences set is backed by an XML file under the app's private storage at /data/data/<package>/shared_prefs/. Because it lives in the app sandbox, the data is private to the app and is removed when the app is uninstalled or when the user clears the app's data.

Cleanup and modern alternatives

Clearing an app's data via Settings > Apps > [app] > Storage > Clear storage wipes the shared_prefs directory, resetting all of the app's preferences — which is why it counts as app data rather than cache and is not removed by a normal cache clear. A cleaner can surface this user-data footprint alongside cache.

For larger or more complex local data Google now recommends Jetpack DataStore, which offers an async, type-safe API over Kotlin coroutines and Flow and avoids common SharedPreferences pitfalls like blocking the main thread with commit(). SharedPreferences remains fine for genuinely small, simple key-value needs.

Related terms

Keep reading the reference.

Recommended solution

The curated tool collection for this kind of cleanup.

Act on it

Guides and tools for this topic.