Home » Android » Android SharedPreference lifecycle

Android SharedPreference lifecycle

Posted by: admin June 15, 2020 Leave a comment

Questions:

In my application I have a few SharedPreference values. The mode is PRIVATE (0), so these preferences are in bounds of application. What I’m interested in, is are they removed after de-installation of the application? Or they still stay somewhere in the system until clear() will be called? Thanks.

How to&Answers:

Deinstalation shall remove shared preferences. APK update preserves them

Answer:

SharedPreferences count as your application data, which is deleted when the app is uninstalled.
I don’t think you can force the device to keep them.

Answer:

SharedPreference will be deleted only:

  1. When the user uninstalls the app.
  2. When the user clears the app data through Settings > Apps.