Home Ask Login Register

Developers Planet

Your answer is one click away!

Robert McLendon February 2016

Why is SharedPreferences persisting after reinstall in Android Studio using emulator?

In my understanding, SharedPreferences data is not supposed to persist after a reinstall. I have coded the logic of my app accordingly.

However, using testing on an emulator in Android Studio, I'm seeing the SharedPreferences persist even after I rebuild and reinstall the app. This occurs even if I close and restart the emulator.

Can anyone explain this (seemingly) odd behavior?


tynn February 2016

SharedPreferences are stored in your internal data directory in XML files. As long as you don't delete your application, these files persist.

From the documentation:

The SharedPreferences class provides a general framework that allows you to save and retrieve persistent key-value pairs of primitive data types. You can use SharedPreferences to save any primitive data: booleans, floats, ints, longs, and strings. This data will persist across user sessions (even if your application is killed).

Post Status

Asked in February 2016
Viewed 1,482 times
Voted 11
Answered 1 times


Leave an answer

Quote of the day: live life