Search code examples
androidsqliteversionrestoredowngrade

Android, how to get the version number of sqlite DB file that backuped in SD card?


Here is my problem:

Preconditions:

1, APP backup the db file to SD card, assuming the DB version is 2.

2, Uninstall APP on phone.

Now, installing an old version APP with old version DB (like, 1).

APP has to restore the backup DB file from SD card for initializing UI.

Problem is that I can NOT get the version number of the backup DB file!

Further more, I can NOT decide should it "upgrade" or "downgrade"!


Solution

  • call SQLiteDatabase.openDatabase(back_up_db_path, null,SQLiteDatabase.OPEN_READWRITE).getVersion() method. May be help you.