From: Damyan Ivanov Date: Sun, 19 Jul 2020 09:04:10 +0000 (+0300) Subject: move setting case_sensitive_like=ON to helper.onOpen X-Git-Tag: v0.15.0~80 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=64bb8277f3c747f0ef2dcb48f898fb4ec07b64ee;p=mobile-ledger.git move setting case_sensitive_like=ON to helper.onOpen executes the query once per app start (db open) instead on each connection request --- diff --git a/app/src/main/java/net/ktnx/mobileledger/App.java b/app/src/main/java/net/ktnx/mobileledger/App.java index 027fc73d..b47e6d7f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/App.java +++ b/app/src/main/java/net/ktnx/mobileledger/App.java @@ -106,7 +106,6 @@ public class App extends Application { initDb(); final SQLiteDatabase db = dbHelper.getWritableDatabase(); - db.execSQL("pragma case_sensitive_like=ON;"); return db; } diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java index b2a01f4d..1b17ca23 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java @@ -55,7 +55,13 @@ public class MobileLedgerDatabase extends SQLiteOpenHelper { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { debug("db", "onUpgrade called"); - for (int i = oldVersion + 1; i <= newVersion; i++) applyRevision(db, i); + for (int i = oldVersion + 1; i <= newVersion; i++) + applyRevision(db, i); + } + @Override + public void onOpen(SQLiteDatabase db) { + super.onOpen(db); + db.execSQL("pragma case_sensitive_like=ON;"); } private void applyRevision(SQLiteDatabase db, int rev_no) {