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