Called to notify of a failure in
#onUpgrade(ISQLiteDatabase,int,int) or
#onDowngrade(ISQLiteDatabase,int,int), either because it returned false or because
an unexpected exception occurred.
The default implementation of this method rethrows the MigrationFailedException parameter. Subclasses can take
drastic corrective action here, e.g. recreating the database with
#recreate(). If instead of calling
recreate() you choose to take other corrective action, you should finish by calling
ISQLiteDatabase#setVersion(int) to reflect that you were able to recover and complete the migration
successfully.
Calling
#getDatabase() or any other DB access method from within this hook is generally unsafe, as the
database is not open when this hook is called, and attempting to reopen it without correcting the problem may
result in recursion, unless you specifically write your
#onUpgrade(ISQLiteDatabase,int,int)or
#onDowngrade(ISQLiteDatabase,int,int) logic to handle such cases. (
#recreate() is
still safe however). You also should not suppress this exception without taking any action. If this method
exits without throwing but the database is not open, another exception will be thrown that is likely to cause
a crash.
Failures to open the database not caused by an error in the migration flow are handled by
the
#onDatabaseOpenFailed(RuntimeException,int) hook.