如何使用新的apk升级prevoius apk而不会丢失来自未知资源apk的android中以前的数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10332116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:20:08  来源:igfitidea点击:

how to upgrade the prevoius apk with new apk without losing the previous data in android from unknown resources apk

androidapk

提问by Rajender Reddy

How to upgrade the android application with out losing previous apk data in real device with new apk ?

如何使用新的 apk 在不丢失真实设备中以前的 apk 数据的情况下升级 android 应用程序?

回答by binW

there is a versionCodeelement in AndroidManifest.xml. This is an integer and its value should be increased for each new version. So the higher the value of this integer, the more recent the version of your app is. So to update your app with apk, you should just increment this number by 1 and recompile your app and use the resulting apk to install your app as you normally would. The data will be automatically saved. This is how hockeyappupdates the app for beta testers.

AndroidManifest.xml 中有一个versionCode元素。这是一个整数,每个新版本都应增加其值。所以这个整数的值越高,你的应用程序的版本就越新。因此,要使用 apk 更新您的应用程序,您只需将此数字增加 1 并重新编译您的应用程序,然后像往常一样使用生成的 apk 安装您的应用程序。数据将自动保存。这就是hockeyapp为 Beta 测试人员更新应用程序的方式。

回答by Boris Strandjev

This is the default behaviour. You will need to to implement special logic if you need to REMOVE the data. Just reinstall the apk.

这是默认行为。如果需要 REMOVE 数据,则需要实现特殊逻辑。只需重新安装apk。

回答by Depado

Try to see if your data are stored in your SD card and copy the containing folder on your computer. But I guess if your data are stored on your SD card, the new apk will try to read it before recreating everything and delete everything. If your data are stored elsewhere, just backup these data.

尝试查看您的数据是否存储在 SD 卡中,然后将包含的文件夹复制到您的计算机上。但我想如果您的数据存储在您的 SD 卡上,新的 apk 会在重新创建所有内容并删除所有内容之前尝试读取它。如果您的数据存储在其他地方,只需备份这些数据。

I don't think updating an apk will destroy your data. One only thing to know when it's risky : Backup on your computer. Hope it will help.

我认为更新 apk 不会破坏您的数据。有风险时唯一需要知道的一件事:在您的计算机上备份。希望它会有所帮助。