Database Onupgrade Method Is Never Called
I'm trying to upgrade my database from version 1 to version 2. I'm assigning DATABASE_VERSION = 2 (first version was assigned too) but onUpgrade never called. May be there is an ob
Solution 1:
Local database version will always be 0 and onUpgrade
will not be called, because you never called getWritableDatabase/getReadableDatabase
, which will bump version and return local db.
So you need:
- make call
getReadableDatabase();
in your contructor/oncreate, just to trigger process, in case db version is changed or - manually check sdcard version,
db.getVersion();
compare to current version -DATABASE_VERSION
. And do what ever you need to do - upgrade or downgrade.
Post a Comment for "Database Onupgrade Method Is Never Called"