views:

48

answers:

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 (beetwen backup and restore) an app update has made changes to the database i get a problem on restoring. The new colums are not there after restoring.

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

Or is there a better way for this?

+1  A: 

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
Thanks, i will try it and post the result.
chrisonline
Yes it works. After restore the database calls onUpgrade.Thanks
chrisonline