From 37e145a9d646800a41a51aee3d346b264e0fd24c Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 11 Dec 2023 21:58:31 +0100 Subject: [PATCH] Wrap pragma queries --- app/src/main/java/eu/faircode/email/DB.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DB.java b/app/src/main/java/eu/faircode/email/DB.java index 9926405b9f..d61315037e 100644 --- a/app/src/main/java/eu/faircode/email/DB.java +++ b/app/src/main/java/eu/faircode/email/DB.java @@ -23,6 +23,7 @@ import androidx.room.RoomDatabase; import androidx.room.TypeConverter; import androidx.room.TypeConverters; import androidx.room.migration.Migration; +import androidx.sqlite.db.SimpleSQLiteQuery; import androidx.sqlite.db.SupportSQLiteDatabase; import org.json.JSONArray; @@ -501,8 +502,8 @@ public abstract class DB extends RoomDatabase { // https://www.sqlite.org/pragma.html for (String pragma : DB_PRAGMAS) - if (!"compile_options".equals(pragma) || BuildConfig.DEBUG) - try (Cursor cursor = db.query("PRAGMA " + pragma + ";")) { + if (!"compile_options".equals(pragma) || BuildConfig.DEBUG) { + try (Cursor cursor = db.query(new SimpleSQLiteQuery("PRAGMA " + pragma + ";"))) { boolean has = false; while (cursor.moveToNext()) { has = true; @@ -510,7 +511,10 @@ public abstract class DB extends RoomDatabase { } if (!has) Log.i("Get PRAGMA " + pragma + "="); + } catch (Throwable ex) { + Log.e(ex); } + } if (BuildConfig.DEBUG && false) dropTriggers(db);