Reputation: 1234
I need to delete the shared preference file from android whenever user downloads the newer version of the app or re-installs the application. How can I achieve this?
Thanks in Advance !!
Cheers, Prateek
Upvotes: 1
Views: 3937
Reputation: 10879
Not only! In fact, to no longer have shared preferences data once the application has been reinstalled, you must enter in Manifest.xml:
<application android:allowBackup="false".../>
Upvotes: 0
Reputation: 1007474
How can I achieve this?
You have no way to detect a reinstall. Fortunately, that never occurs except during development, AFAIK.
To detect a version upgrade, store a copy of your versionCode
in a preference. Compare it to the running copy when your code starts up. If your app is newer than the versionCode
in the preference, your app has been updated, and you can do whatever you feel you need to do.
Note, though, that this is rather unusual behavior, and users may give you poor ratings on the Market if they feel that they are losing information because of an upgrade.
Upvotes: 6