Search code examples
databaseandroidsqliteversioningdowngrade

Downgrading DB on Android


I tested that it is possible for Android to pass newVersion < oldVersion to SQLiteOpenHelper.onUpgrade() method, ie. it wants the application to downgrade its database.

I don't want to handle this case, though I would like to notify the user somehow that there exists a newer version of my application (which she apparently had installed previously) and that's the one she should be using.

Any ideas what would be the best way to achieve this? Toast? AlertDialog (but in what context)?


Solution

  • Indeed, you can call that method with a "new" version smaller than the "old" version, but when would it ever happen?

    Unless you expect your users to manually reinstall your app, overwriting it with an earlier APK, there's no need to think about this.