]> git.ktnx.net Git - mobile-ledger.git/commitdiff
open SQLite db with write-ahead logging enabled
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 16 Dec 2018 17:16:37 +0000 (17:16 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 16 Dec 2018 17:16:37 +0000 (17:16 +0000)
this allows writers not to block readers

app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java

index 5fd4e0e6b4a81d021a836bd430f014e7aa554eb8..9d8950a6c373c925bd89176b49c4abb8c6ca6b0e 100644 (file)
@@ -35,7 +35,8 @@ import static net.ktnx.mobileledger.utils.MLDB.DatabaseMode.READ;
 import static net.ktnx.mobileledger.utils.MLDB.DatabaseMode.WRITE;
 
 public final class MLDB {
-    public enum DatabaseMode { READ, WRITE };
+    public enum DatabaseMode {READ, WRITE}
+
     public static final String ACCOUNTS_TABLE = "accounts";
     public static final String DESCRIPTION_HISTORY_TABLE = "description_history";
     private static MobileLedgerDatabase helperForReading, helperForWriting;
@@ -124,6 +125,7 @@ class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable {
         super(context, DB_NAME, null, LATEST_REVISION);
         Log.d("db", "creating helper instance");
         mContext = context;
+        super.setWriteAheadLoggingEnabled(true);
     }
 
     @Override