发生在更新的Andr​​oid应用程序共享preferences

发生在更新的Andr​​oid应用程序共享preferences

本文介绍了会发生在更新的Andr​​oid应用程序共享preferences什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经存储在共享preferences在我的应用程序的用户设置。将与共享preferences发生什么,当我更新通过谷歌的应用Play商店的应用程序的新版本?

I've stored user settings in the SharedPreferences in my App. What will happen with the SharedPreferences when I update the App via Google Play Store to a new version of the App?

将共享prefernces仍然在更新后在那里还是会被删除?

Will the SharedPrefernces still be there after the update or will they be deleted?

到目前为止,我还没有发现(我可能会与错误的关键词搜索?)。

So far I haven't found an answer on the web or Stackoverflow (may I search with wrong keywords?).

您可以点我到一些链接,他们描述了这一过程?

Can you point me to some links they describe this process?

编辑:同时我发现了对方的回答太:<一href="http://stackoverflow.com/questions/7103453/shared$p$pferences-update-unisntall">Shared$p$pferences - 更新/ Unisntall

Meanwhile I found a other answer too: SharedPreferences - Update/Unisntall

推荐答案

克里斯蒂安这里说:你的应用程序数据将继续当用户安装更新。

Cristian here says: your Application data will be remain when user install updates.

但必须使用相同的包的名称来检测为previous应用程序的更新。

But it must be with the same package name to detect as an update of previous App.

EboMike在Warning ?Android的用户该应用程序的更新可能会导致从旧的应用程序版本丢失数据说:

EboMike in Warning Android user that app update could lead to losing data from old app version? says:

坦率地说,数据丢失是由于升级是不可接受的。

修改

,共享preferences(以及其它用户数据)在更新过程将被保留,但有时,由于一些的未知的问题,数据可能丢失,我想这是在你的控制。所以,你可以简单地认为共享preferences将被保留(见这里)。

Normally, the SharedPreferences(as well as other user data) will be kept during the update process, but sometimes, due to some "unknown" problem, the data may get lost, and I guess it is out of your control. So, you can simply believe that the SharedPreferences will be kept(see here).

所以,如果你想避免在升级正在进行清除用户数据,你必须保存在外部存储主数据(这可能是一个可移动存储介质,如SD卡或内部,不可移动,存储。 ),而不是私人你App.Or至少放好供用户备份数据的(升级)应用程序的第一次运行升级。那么之前,请检查是否有在外部存储的任何备份文件或没有。

So,if you want to avoid clearing user's data in upgrading progress,you have to save main data in external storage(this can be a removable storage media,such as an SD card or an internal,non-removable, storage.) and not private for your App.Or at least put away for user to backup data before upgrading .Then in first run of your (upgraded) App,check that is there any backup file in external storage or no.

如果你想知道的什么东西必须/可升级应用程序怎样?,我没有什么好说明this.It是复杂的,相对与 Android的安全性应用程序签署复制保护等话题。我的意思是,如果你改变任何上述领域的应用程序的状态,它会导致不同的结果。
例如,如果您时拷贝保护从开到关或从关到开,您的应用程序将被更新,但会导致所有的共享preferences迷路,文件访问是不可能的......。
你虽然必须要照顾有关情况会导致新的应用程序正在审议为previous更新应用程序(见的)。

If you like to know What things must/can happen on upgrading an App?,I did not any good description for this.It is complicated and relative with Android Security,Application signing,copy protection and other topics.I mean that if you change state of your App in any above fields,it causes different result.
For example if you CHANGED COPY PROTECTION FROM ON to OFF OR OFF to ON,your App will be updated but causes all your shared preferences to get lost,file access be impossible and ... .
You although have to be care in about conditions cause your new App being considered as an update for previous App(see Things That Cannot Change).

另外,你必须照顾你的code,可能导致删除您的数据库中的数据(见的更新应用程序)。

Also you have to be care in about your code,it may be caused deleting data of your databases(see update app with preloaded SQLite).

但最终,如果要小心,你可以说:

更新过程只替换apk文件(所以它是什么了  例如可绘,...),并不会改变数据库,共享preferences  并且在运行时(可能产生的任何其它的文件  情况下,新的应用程序是与UID等于的UID安装  previous应用程序)。

您可以看到这些网页了解更多详情:

You can see these pages for more details:

帮助!更新我们的applicatoin在市场上删除存储的共享preferences。
市场版权保护完全打破了更新
后,文件的访问有人可以解释的应用程序更新过程?

Help!? Updating our applicatoin on the market deletes the saved SharedPreferences.
Market copy protection totally breaks file access after updating
Can someone explain the App update process?

这篇关于会发生在更新的Andr​​oid应用程序共享preferences什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:17