开发者

How to delete the shared preference file from Android application when re-installing or updating?

I need to delete the shared preference file from android whenever user downloads the newer version of th开发者_JAVA百科e 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.


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".../>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜