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?
2 Answers
No, the Shared Preferences will remain.

- 198,401
- 62
- 356
- 264
-
21This is also nothing personal, but although testing should be the ultimate endpoint to the question, it is nice for someone like me to be able to do a simple search and get a quick answer. I only say this because as a noob, questions like this pop into my head AS I'm programming. Now, I can move forward without worrying about said question, but one should STILL test everything. – dell116 Mar 20 '11 at 20:03
-
Its a different question, but how to delete the shared preferences when application is updated or reinstalled? – Prateek Jain Apr 19 '11 at 18:47
-
1It's easy, but you have to open another question for that. – Cristian Apr 19 '11 at 20:06
-
I would rather google and find the answer than test an update app and check log out zzZ :p – Blundell Mar 16 '12 at 08:49
-
14@Cristian - small questions like these are incredibly valuable - I typed my question into google and got this post, and hence the answer to the same question in about 3 seconds. – Louis Sayers Aug 31 '12 at 15:20
-
@Louis Sayers - I agree 100% with Louis Sayers. This post saved me 10 minutes of valuable time. Thanks for the answer, though! – Matt W Sep 13 '12 at 02:09
-
@Cristian StackOverflow saves me so much development time BECAUSE OF answers to simple questions such as this. – theblang Feb 13 '14 at 16:22
-
Another note: make sure the shared preference name is the SAME between upgrades! I had different names between versions, and so the new version isn't picking up the saved preferences from previous version... wasted an entire morning to debug this... :-( – henrykodev Mar 23 '16 at 03:16
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.

- 22,342
- 9
- 83
- 103