如何重新安装或更新时,删除共享preference从Android应用程序文件? [英] How to delete the shared preference file from Android application when re-installing or updating?

查看:286
本文介绍了如何重新安装或更新时,删除共享preference从Android应用程序文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从Android删除共享preference文件,只要用户下载该应用程序的新版本或重新安装应用程序。我怎样才能做到这一点?

先谢谢了!

干杯,
Prateek


解决方案

  

我怎样才能做到这一点?


您没有办法检测到重新安装。幸运的是,从来没有发生,除了在开发过程中,据我所知。

要检测一个版本升级,存储你的版本code 的副本在preference。当你的code启动比较到正在运行的副本。如果您的应用程序比版本code 在preference更新,您的应用程序已经更新,你可以做任何你觉得你需要做的。

但是请注意,这是相当不寻常的行为,而且用户可以给你差评的市场,如果他们觉得自己正在失去,因为升级的信息。

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.

这篇关于如何重新安装或更新时,删除共享preference从Android应用程序文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆