I am using room database in my compose multiplatform project, but some android devices showing this error: Exception android.database.SQLException: Error code: 5, message: database is locked . Error showing only Google Play Android Vitals history, while I am testing in my devices no error there.
Copy code
fun getDatabase(ctx: Context): AppDatabase {
val dbFile = ctx.getDatabasePath(dbFileName)
return Room.databaseBuilder<AppDatabase>(
context = ctx,
name = dbFile.absolutePath,
)
.setDriver(BundledSQLiteDriver())
.setQueryCoroutineContext(<http://Dispatchers.IO|Dispatchers.IO>)
.fallbackToDestructiveMigration(true)
.enableMultiInstanceInvalidation()
.allowMainThreadQueries()
.build()
}
actual fun platformModule(context: Any?) = module {
single<AppDatabase> { getDatabase(context as Context) }
}