0

I developed an Android application. I installed the apk on my tablet.

Now, I want just modify few code lines and one table of my SQLite database, but I don't want reinstall my apk, I want make an upgrade.

How can I build this upgrade mechanism?

GVillani82
  • 17,196
  • 30
  • 105
  • 172

2 Answers2

3

Android doesn't provide a "patch" mechanism. You need to create a new APK and install it over the existing application.

David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • Can I preserve the data in my database? – GVillani82 Oct 08 '12 at 13:07
  • 1
    Yes. If the user installs the new APK while the old application is installed, Android will update the application (which will preserve any data in your private data areas, including database). However, if you are changing the schema or content of your database, you may need to "upgrade" your database as well. See `SQLiteOpenHelper.onUpgrade()` at http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html – David Wasser Oct 08 '12 at 13:12
  • ok. And Can I call the installation of new apk from the old running apk? – GVillani82 Oct 08 '12 at 13:18
  • Yes. See http://stackoverflow.com/questions/4967669/android-install-apk-programmatically/4969421#4969421 – David Wasser Oct 08 '12 at 13:22
  • you are always precious! Thank you! :) – GVillani82 Oct 09 '12 at 08:53
3

Yes, you can preserve the data in your database. There is a method onUpgrade in SQLiteOpenHelper which you can override to modify your table(s).

Hassan Jawed
  • 1,650
  • 1
  • 12
  • 19