1

I need to test my onUpgrade() method (I changed a couple of tables in a db) before posting my new version of the app online.

If I install the current version of the application on my mobile and then run the new version of the app on Android Studio while my mobile is connected, will this trigger the upgrade? Is it considered a valid test?

Bhushan
  • 41
  • 5
GG M
  • 13
  • 3

1 Answers1

0

Yes that is valid if you follow the simple rules.

Change the version number of your database in the SqliteOpenHelper otherwise OnUpgrade() will never be called.

Ensure both the old app and the new app are signed with the same signature otherwise, you cannot upgrade from the earlier version to the later one. You may need to temporarily sign your debug build with your release key.

Then just install old app, make sure you do whatever you need to do to ensure the database is created. Update to the new app and test.

For reference: Confusion: How does SQLiteOpenHelper onUpgrade() behave? And together with import of an old database backup?

Kuffs
  • 35,581
  • 10
  • 79
  • 92