Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 194897da authored by Vasu Nori's avatar Vasu Nori
Browse files

journal_mode should be set only on non-memory databases

setting journal_mode to TRUNCATE on memory databases causes an error message
to be displayed by SQLIteDatabase.

Change-Id: Ie8b8ae22cb9fba99cee59dba35b260195c63eadc
parent f3b0d617
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -956,11 +956,14 @@ public class SQLiteDatabase extends SQLiteClosable {
        }
        sqliteDatabase.setPageSize(sBlockSize);

        // set journal_mode to truncate
        // set journal_mode to truncate for non-memory databases
        if (!path.equalsIgnoreCase(":memory:")) {
            String s = DatabaseUtils.stringForQuery(sqliteDatabase, "PRAGMA journal_mode=TRUNCATE",
                    null);
            if (!s.equalsIgnoreCase("TRUNCATE")) {
            Log.e(TAG, "setting journal_mode to TRUNCATE failed");
                Log.e(TAG, "setting journal_mode to TRUNCATE failed for db: " + path +
                        " (on pragma set journal_mode, sqlite returned:" + s);
            }
        }

        // add this database to the list of databases opened in this process