Move the KeyValueDatabase to a separate physical database.

This commit is contained in:
Greyson Parrelli
2021-01-05 11:50:20 -05:00
committed by Alan Evans
parent 46d412a6c3
commit c466dba8c4
10 changed files with 228 additions and 50 deletions

View File

@@ -18,6 +18,10 @@ public final class CursorUtil {
return cursor.getInt(cursor.getColumnIndexOrThrow(column));
}
public static float requireFloat(@NonNull Cursor cursor, @NonNull String column) {
return cursor.getFloat(cursor.getColumnIndexOrThrow(column));
}
public static long requireLong(@NonNull Cursor cursor, @NonNull String column) {
return cursor.getLong(cursor.getColumnIndexOrThrow(column));
}

View File

@@ -27,6 +27,16 @@ public final class SqlUtil {
}
}
public static boolean isEmpty(@NonNull SQLiteDatabase db, @NonNull String table) {
try (Cursor cursor = db.rawQuery("SELECT COUNT(*) FROM " + table, null)) {
if (cursor.moveToFirst()) {
return cursor.getInt(0) == 0;
} else {
return true;
}
}
}
public static boolean columnExists(@NonNull SQLiteDatabase db, @NonNull String table, @NonNull String column) {
try (Cursor cursor = db.rawQuery("PRAGMA table_info(" + table + ")", null)) {
int nameColumnIndex = cursor.getColumnIndexOrThrow("name");