1

How can I call the onUpgrade Method of the database?

Background of my question: I do a backup on the sdcard of the full database. And the user can restore this database.

But, if in the meantime (between backup and restore) an app update changes to the database, I will get a problem on restoring. The new columns are not there after restoring.

So I want to call the onUpgrade method to add all new/changed columns.

Or is there any better way for this?

Dhasneem
  • 4,037
  • 4
  • 33
  • 47
chrisonline
  • 6,949
  • 11
  • 42
  • 62

1 Answers1

3

After a restore, close all open handles to the database, then use your SQLiteOpenHelper to get a writable database. That should trigger onUpgrade() to be called, AFAIK.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491