Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SharedPreferences not reset on reinstall

I have a SharedPreference that counts the amount of launches of my App. I expect this to be 0, when I install my app. Nevertheless it is 14. The same strange behaviour I observe with my database, that already exists on a fresh install.

I didn't intent to recycle my app data (like in the Google Cloud). On my device in the account settings the app-data sync is on. If I turn it off, and make a reinstall I observe the same behaviour.

Anyone has every observed such a behaviour? Is there any way to prevent recycling old data and force a proper install?

like image 318
Anthea Avatar asked Jan 23 '17 14:01

Anthea


1 Answers

In Android Marshmallow Google introduced the "Auto Backup" feature which is turned on by default if your targetSdkVersion is >=23.

This will back up your database and SharedPreferences by default and restore it when you re-install the application. To turn this feature off you have to add android:allowBackup="false" to your AndroidManifest.xml.

More info here: Auto Backup for Apps

like image 168
Mauin Avatar answered Nov 18 '22 01:11

Mauin