android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY)
Another connection holds a write lock on the SQLite database.
SQLiteDatabaseLockedException database is lockedSQLITE_BUSY database is lockeddatabase is locked code 5android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY): , while compiling: PRAGMA journal_mode Meaning
Concurrent writers collide. Use one database instance, enable WAL mode, keep transactions short and avoid opening several helpers for the same file.
Common causes
- Multiple SQLiteOpenHelper instances
- Long write transaction
- Writes from several processes
⚡ Quick fix
- Use a singleton database
- Enable WAL (Room does by default)
- Shorten transactions
Detailed fix by platform
Kotlin
Room.databaseBuilder(ctx, Db::class.java, "app.db").setJournalMode(JournalMode.WRITE_AHEAD_LOGGING).build()
How to diagnose
- Instances — one?
- WAL — enabled?
- Processes — how many?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Cannot access database on the main thread Room: Cannot access database on the main thread since it may potentially lock the UI for a long period of time
- CorruptionException: Unable to parse preferences proto androidx.datastore.core.CorruptionException: Unable to parse preferences proto
- CursorWindow: Window is full: requested allocation bytes android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed
Most viewed in Android
- Could not resolve Gradle: Could not resolve all files for configuration / Could not resolve dependency
- INSTALL_FAILED_USER_RESTRICTED INSTALL_FAILED_USER_RESTRICTED: Install canceled by user (Xiaomi/MIUI, Oppo, Vivo)
- INSTALL_PARSE_FAILED_NO_CERTIFICATES INSTALL_PARSE_FAILED_NO_CERTIFICATES / App not installed as package appears to be invalid
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 25 Nov 2026