In my app I am inserting data in my SQLite database using ORMLite. On some devices I get the following error when inserting data:
02-05 09:29:56.864 22365-22441/com.app E/SQLiteLog﹕ (5) statement aborts at 2: [PRAGMA journal_mode=PERSIST]
02-05 09:29:56.864 22365-22441/com.app W/SQLiteConnection﹕ Could not change the database journal mode of '/data/data/com.app/databases/app.db' from 'wal' to 'PERSIST' because the database is locked. This usually means that there are other open connections to the database which prevents the database from enabling or disabling write-ahead logging mode. Proceeding without changing the journal mode.
I have no idea how I can fix this problem for ORMLite. Does anyone have a fix for my problem? Only accessing one SQLOpenHelper isn't going to solve my problem since I am using ORMLite and don't use the SQLOpenHelper directly from my code.
I think I got a solution. I executed the following code from each of my DatabaseManagers:
SQLiteDatabase db = helper.getWritableDatabase();
Cursor cursor = db.rawQuery("PRAGMA journal_mode = WAL;", null);
cursor.close();
I get a lot less statement aborts errors but I am still getting a few of them. Should I run that code after every query or is this not a good solution?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With