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
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.
SharedPreference data. You will need to handle the delete-file-on-update yourself, as the vast majority of Android applications should not be doing that.