有关Android应用程序更新的问题 [英] Questions about Android application update

查看:202
本文介绍了有关Android应用程序更新的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个问题:


  1. 升级应用程式对储存资料(偏好设定和资料库)有什么影响?系统是否执行新版本的干净安装(即删除旧版本,然后安装新版本)或其他?

  1. What implications does upgrading an app have on stored data i.e. Preferences and database? Does the system perform a clean install of the new version(i.e. remove the older version and then install the new) or something else?

如果用户想要保留存储的数据,例如共享首选项或sqlite数据库中的值,该怎么办?

What if the user wants to retain the stored data- say values in the shared preference or a sqlite database?

如何模拟这个应用程式更新安装方案?如果我有一个版本'x'安装在我的emualator上,我做一个adb安装版本'x + 1',我得到 INSTALL_FAILED_ALREADY_EXIST 错误。

How can I emulate this app-update-install scenario? If I have a version 'x' installed on my emualator and I do a adb install of version 'x+1' I am getting INSTALL_FAILED_ALREADY_EXIST error. Should I try hosting the new apk on a Web server, will the Package Manager take this as an update?


推荐答案


  1. 所有数据仍然存在(文件,首选项,数据库)。数据库是特别的,因为您可以指定数据库版本,如果它检测到更改的版本,它会调用 onUpgrade()

  2. 正如我在1中所说,Android会保留所有内容。

  3. 使用 adb install -r /path/to/newApk.apk(注意 -r 标志,它告诉adb到 r einstall)。基本上,工作流程应如下:

  1. All data persists (files, preferences, databases). Databases are special as you can specify a database version and if it detects the version changed it will call your onUpgrade(). For all others you're responsible of updating them to the new version, if needed.
  2. As I said in 1, Android persists everything. It's up to you to handle any changes in the way you store your data.
  3. Use adb install -r /path/to/newApk.apk (notice the -r flag, which tells adb to reinstall). Basically, the workflow should be the following:

adb uninstall my.package
adb install /path/to/old.apk
# play with app, set preferences, databases, etc.
adb install -r /path/to/new.apk
# watch your app crash in an impressive ball of fire
# fix stuff
# goto 0

其他说明:是的,应用程序会在安装新版本之前对您的应用程序执行清除删除操作。正如我所说,您的应用程式的资料并未移除。但是,您必须小心,因为此删除操作会导致以下几种情况:

Other notes: Yes, the app performs a clean removal of your app before installing the new version. As I said, however, your app's data is not removed. Still, you have to be careful, because this removal causes a few things:


  • 与您的应用程序相关的任何进程都会被终止

  • 与您的应用程序相关的任何内容都会从系统中删除,例如通过<$ c $推送的通知c> NotificationManager ,通过 AlarmManager 等设置的警报。我不知道你可能有什么小部件)。

  • Any processes related to your app are killed (so if your app is running -- any activities, services, anything, all components will be killed).
  • Anything related to your app is removed from the system, like notifications pushed via the NotificationManager, alarms set via the AlarmManager, etc. I'm not sure what happens to any widgets you might have (never worked with widgets).

这篇关于有关Android应用程序更新的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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