Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Shared Preferences are lost sometimes

Tags:

People also ask

Where are shared preferences stored Android?

Android Shared Preferences Overview Android stores Shared Preferences settings as XML file in shared_prefs folder under DATA/data/{application package} directory. The DATA folder can be obtained by calling Environment.

When the shared preference file got deleted from device?

when you do clear data from the device applications manager or when you uninstall your application, the SharedPreference's file is deleted. unless you have the android:allowBackup="true" in your manifest. In that case they might be restored.

Does uninstalling app clear shared preferences?

The shared preference is definitely deleted when the application is uninstalled.

Can shared preferences be deleted?

SharedPreferences is what Android and iOS apps use to store simple data in an allocated space. This data exists even when the app is shut down and starts up again; we can still retrieve the value as it was. The data stored in SharedPreferences can be edited and deleted.


Some of the users of my application complain that sometimes (in a random way) the settings of my application are getting reverted to their default state (usually after a reboot of the phone). I never managed to reproduce the problem though. I am thinking it is due to the fact that in many places in my app I have a piece of code that calls the shared preferences editor and commits changes - Can it resolves in corrupting the shared preference file if I try to commit several changes to the same preference file at the same time? (Multi-thread application)

I am really lost. I tried to look in the web for hours to find a solution without a success.

If anyone has even an idea so I can start investigating, I would be grateful.

Thanks, Amit Moran