Refactoring

This commit is contained in:
M66B 2021-12-01 08:24:36 +01:00
parent e476a6f3bf
commit ec69dc6680
1 changed files with 10 additions and 7 deletions

View File

@ -129,6 +129,15 @@ public abstract class DB extends RoomDatabase {
private static final String[] DB_TABLES = new String[]{
"identity", "account", "folder", "message", "attachment", "operation", "contact", "certificate", "answer", "rule", "search", "log"};
private static final String[] DB_PRAGMAS = new String[]{
"synchronous", "journal_mode",
"wal_checkpoint", "wal_autocheckpoint", "journal_size_limit",
"page_count", "page_size", "max_page_count", "freelist_count",
"cache_size", "cache_spill",
"soft_heap_limit", "hard_heap_limit", "mmap_size",
"foreign_keys"
};
@Override
public void init(@NonNull DatabaseConfiguration configuration) {
// https://www.sqlite.org/pragma.html#pragma_wal_autocheckpoint
@ -414,13 +423,7 @@ public abstract class DB extends RoomDatabase {
}
// https://www.sqlite.org/pragma.html
for (String pragma : new String[]{
"synchronous", "journal_mode",
"wal_checkpoint", "wal_autocheckpoint", "journal_size_limit",
"page_count", "page_size", "max_page_count", "freelist_count",
"cache_size", "cache_spill",
"soft_heap_limit", "hard_heap_limit", "mmap_size",
"foreign_keys"})
for (String pragma : DB_PRAGMAS)
try (Cursor cursor = db.query("PRAGMA " + pragma + ";")) {
Log.i("Get PRAGMA " + pragma + "=" + (cursor.moveToNext() ? cursor.getString(0) : "?"));
}