Android “remembers” shared preferences after complete app uninstall

后端 未结 3 584
耶瑟儿~
耶瑟儿~ 2020-12-20 06:59

In my Android app I use a set of randomly generated file names to store some data. In order to ensure that the same set of file names are generated at app restart - and are

3条回答
  •  庸人自扰
    2020-12-20 07:44

    Based on @hungryghost's suggestion the I eventually implemented a solution

    Problem:Shared preferences can be remembered by Android after app reinstall and blanket instructions in the manifest along the lines of android:allowBackup = "false" are not a solution.

    So why not turn the problem into a solution on its own? Here is what I do

    • Check shared preferences for a build specific key.
    • If that key is not found I do two things

      1. Clear out all shared preferences, context.deleteSharedPrefernces(filename)
      2. Now create that build specific key
      3. When I make app changes that require old preferences to be forgotten I simply change the build specific key.

提交回复
热议问题