Modify WAL checkpoint in debug version only

pull/172/head
M66B 5 years ago
parent fb2c1e21ca
commit e3ee1cc4b2

@ -110,12 +110,14 @@ public abstract class DB extends RoomDatabase {
@Override
public void init(@NonNull DatabaseConfiguration configuration) {
// https://www.sqlite.org/pragma.html#pragma_wal_autocheckpoint
File dbfile = configuration.context.getDatabasePath(DB_NAME);
if (dbfile.exists()) {
try (SQLiteDatabase db = SQLiteDatabase.openDatabase(dbfile.getPath(), null, SQLiteDatabase.OPEN_READWRITE)) {
Log.i("DB checkpoint=" + DB_CHECKPOINT);
try (Cursor cursor = db.rawQuery("PRAGMA wal_autocheckpoint=" + DB_CHECKPOINT + ";", null)) {
cursor.moveToNext(); // required
if (BuildConfig.DEBUG) {
File dbfile = configuration.context.getDatabasePath(DB_NAME);
if (dbfile.exists()) {
try (SQLiteDatabase db = SQLiteDatabase.openDatabase(dbfile.getPath(), null, SQLiteDatabase.OPEN_READWRITE)) {
Log.i("DB checkpoint=" + DB_CHECKPOINT);
try (Cursor cursor = db.rawQuery("PRAGMA wal_autocheckpoint=" + DB_CHECKPOINT + ";", null)) {
cursor.moveToNext(); // required
}
}
}
}

Loading…
Cancel
Save