开发者

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

开发者 https://www.devze.com 2023-01-19 04:34 出处:网络
If I store some user settings and information in shared preferences in my android apps, and then I update the app in 开发者_Python百科the Market, will those settings be erased when the app updates?No,

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


No, the Shared Preferences will remain.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消