mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 18:30:20 +01:00
Move the KeyValueDatabase to a separate physical database.
This commit is contained in:
committed by
Alan Evans
parent
46d412a6c3
commit
c466dba8c4
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user