Ben Mc
Ben Mc

Reputation: 2078

Are shared preferences in Android apps deleted when a user updates the app?

If I store some user settings and information in shared preferences in my android apps, and then I update the app in the Market, will those settings be erased when the app updates?

Upvotes: 35

Views: 8640

Answers (2)

Lazy Ninja
Lazy Ninja

Reputation: 22527

To make the answer simple: NO in normal circumstances.

The update process only replaces the apk file(and so what is in it for example drawables,...) and does not alter databases,sharedpreferences and any other files that generated in run time(probably in this case,new App is installed with the UID that is equal to UID of previous App).


But following this thread it seems that there are cases when data could be lost. Like changing Copy PROTECTION FROM ON to OFF OR OFF to ON.
Quoting the answer:

It turns out when we posted the update copy protection was turned off, but for our initial release it was turned on. Which caused all our shared preferences to get lost, we could no longer create private data files, and the game started randomly crashing.

Upvotes: 2

Cristian
Cristian

Reputation: 200080

No, the Shared Preferences will remain.

Upvotes: 38

Related Questions