A few questions :
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?
What if the user wants to retain the stored data- say values in the shared preference or a sqlite database?
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?
onUpgrade()
. For all others you're responsible of updating them to the new version, if needed.adb install -r /path/to/newApk.apk
(notice the-r
flag, which tells adb to reinstall). Basically, the workflow should be the following:.
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:
NotificationManager
, alarms set via theAlarmManager
, etc. I'm not sure what happens to any widgets you might have (never worked with widgets).onUpgrade()
method i.e.