Some of the live users of my app are experiencing SQLite database corruption. When we have collected log from users we found below details:
E/SQLiteLog(14085): (11) database corruption at line 57189 of [b3bb660af9]
E/SQLiteLog(14085): (11) Invalid page count: nPage: 52, nPageFile: 50
E/SQLiteLog(14085): (11) lockBtree() error, rc: 11, printing out first page (size: 32768) of DB /data/data/com.app.testpackagename/files//db/statictext_v3.0_DE.db
E/SQLiteLog(14085): (11) Page (1) has been corrupted
E/SQLiteLog(13318): (11) database disk image is malformed
E/DefaultDatabaseErrorHandler(13318): Corruption reported by sqlite on database: /data/data/com.app.testpackagename/files//db/statictext_v3.0_DE.db
E/SQLiteLog(13318): (11) database corruption at line 57189 of [b3bb660af9]
E/SQLiteLog(13318): (11) Invalid page count: nPage: 52, nPageFile: 50
E/SQLiteLog(13318): (11) lockBtree() error, rc: 11, printing out first page (size: 32768) of DB /data/data/com.app.testpackagename/files//db/statictext_v3.0_DE.db
E/SQLiteLog(13318): (11) Page (1) has been corrupted
The corrupt database is the Static database (it has preloaded records and we are not doing any Insert, Update, Alter, Delete except Select data from it.
This database is in assets of my app and I'm mounting it to device and obtaining its object with
this.staticDb = SQLiteDatabase.openDatabase(AppDelegate.getFileDirectory() + "/" + SDCARD_FOLDER_NAME +DB_FOLDER_NAME + "/" + Dbpath, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
I want to handle this exception with DefaultDatabaseErrorHandler by using onCorruption
method of this class but not getting any proper documentation for implementation. Can I use this class in my case?
SQLiteDatabase.openDatabase(context.getFileDirectory() + "/" + "sd_card_name" + "db_folder_name" + "/" + "dbPath",
null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY,
new DatabaseErrorHandler() {
@Override
public void onCorruption(SQLiteDatabase dbObj) {
//do whatever you want to do
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With