简体   繁体   中英

Android: SQLite: If isDatabaseIntegrityOK() returns false

if SQLiteDatabase.isDatabaseIntegrityOK() returns false, how do i get access to the 1-100 lines of logs the database is supposed to return?

I want to display the results of the integrity check in my Android app.

Thanks!

Just execute the command yourself, and pretend that it's a SELECT :

Cursor cursor = db.rawQuery("PRAGMA integrity_check", null);
while (cursor.moveToNext()) {
    String s = cursor.getString(0);
    ...
}

Alternative using Android's DatabaseUtils:

StringBuilder sb = new StringBuilder();
DatabaseUtils.dumpCursor(db.rawQuery("PRAGMA integrity_check", null), sb);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM