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

后端 未结 2 1610
悲哀的现实
悲哀的现实 2020-12-06 03:58

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 u

相关标签:
2条回答
  • 2020-12-06 04:25

    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 讨论(0)
  • 2020-12-06 04:40

    No, the Shared Preferences will remain.

    0 讨论(0)
提交回复
热议问题