Android-Debug-Database
Android-Debug-Database copied to clipboard
[PRAGMA journal_mode=TRUNCATE] database is locked With Room
This is a cool library to check datasbe. But when using with Room i was seeing this log in my logcat.
2019-05-27 04:46:06.569 3634-3691/com.test E/SQLiteLog: (5) statement aborts at 1: [PRAGMA journal_mode=TRUNCATE] database is locked
2019-05-27 04:46:06.579 3634-3691/com.test W/SQLiteConnection: Could not change the database journal mode of '/data/user/0/com.test/databases/MyDb' from 'wal' to 'TRUNCATE' 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.
It took me 1 day to figure out that this library was causing this issue.
Can you confirm this?
android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: PRAGMA journal_mode
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:890)
at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:635)
at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:321)
at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:295)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:216)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:194)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:493)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:200)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:192)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:864)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:849)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:750)
at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:767)
at com.amitshekhar.debug.sqlite.DebugDBFactory.create(DebugDBFactory.java:13)
at com.amitshekhar.server.RequestHandler.openDatabase(RequestHandler.java:187)
at com.amitshekhar.server.RequestHandler.getTableListResponse(RequestHandler.java:306)
at com.amitshekhar.server.RequestHandler.handle(RequestHandler.java:113)
at com.amitshekhar.server.ClientServer.run(ClientServer.java:77)
at java.lang.Thread.run(Thread.java:764)
This is my issue! When i use ROOM database and androidx.
Also experiencing this issue here!

can any one help on solving the issue for instance? even after removing the library implementation, it is giving the same error.
My issue occurs when I use the Firebase Database. And I remove this code to resolve issue:
FirebaseDatabase.getInstance().setPersistenceEnabled(true);