Added fail-safe

pull/205/head
M66B 3 years ago
parent 9edadfaafa
commit 127baee746

@ -401,6 +401,7 @@ public abstract class DB extends RoomDatabase {
Log.i("Get PRAGMA " + pragma + "=" + (cursor.moveToNext() ? cursor.getString(0) : "?"));
}
try {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
int class_mb = am.getMemoryClass();
int cache_size = class_mb * 1024 * 100 / DB_CACHE_PERCENTAGE;
@ -414,6 +415,9 @@ public abstract class DB extends RoomDatabase {
try (Cursor cursor = db.query("PRAGMA cache_size;")) {
Log.i("Get PRAGMA cache_size=" + (cursor.moveToNext() ? cursor.getInt(0) : "?"));
}
} catch (Throwable ex) {
Log.e(ex);
}
Log.i("Set PRAGMA cache_spill=0");
try (Cursor cursor = db.query("PRAGMA cache_spill=0;", null)) {

Loading…
Cancel
Save