Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Questions about Android application update

A few questions :

  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?

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

  3. 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?

like image 897
Samuh Avatar asked Nov 10 '10 11:11

Samuh


People also ask

What two things are required to develop Android applications?

Master the LanguageJava and XML are the two main programming languages used in Android App development. Knowledge and mastery over these programming languages are, therefore, prerequisites to developing an Android app.

How Android is useful for mobile application development?

Android Development is low cost and provides high ROI. Since Android has a huge number of clients from increasingly diverse backgrounds, applications are less expensive. Most of the applications are free to download and are also easily available on the play store in comparison to another operating system.

Which system can be used for development of Android application?

Android apps can be written using Kotlin, Java, and C++ languages. The Android SDK tools compile your code along with any data and resource files into an APK or an Android App Bundle.

How are Android applications developed?

Android software development is the process by which applications are created for devices running the Android operating system. Google states that "Android apps can be written using Kotlin, Java, and C++ languages" using the Android software development kit (SDK), while using other languages is also possible.

What is Android and why it is becoming an important application for software development?

Android is a platform that is easier to master for developers having varying skill levels. Mobile app development services can utilize Android with much greater ease than any other platform. Android uses Java which is a programming language that most developers are intimately familiar with.

Which types of flags are used to run an application on Android?

Following are two types of flags to run an application in Android: FLAG_ACTIVITY_NEW_TASK. FLAG_ACTIVITY_CLEAR_TOP.


1 Answers

  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:

  • 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).
like image 198
Felix Avatar answered Oct 16 '22 08:10

Felix