how to add sqlite driver to kmp for room ```Cannot...
# multiplatform
c
how to add sqlite driver to kmp for room
Copy code
Cannot create a RoomDatabase without providing a SQLiteDriver via setDriver().
I have added these lines:
Copy code
val roomVersion = "2.7.0-alpha12"
    implementation("androidx.room:room-runtime:$roomVersion")
    implementation("androidx.sqlite:sqlite-bundled:2.5.0-alpha12")
    implementation("androidx.sqlite:sqlite-bundled-jvm:2.5.0-alpha12")
    ksp("androidx.room:room-compiler:$roomVersion")
creation code:
Copy code
fun getDatabaseBuilder(): RoomDatabase.Builder<AppDatabase> {
    val dbFile = File(System.getProperty("java.io.tmpdir"), "my_room.db")
    return Room.databaseBuilder<AppDatabase>(
        name = dbFile.absolutePath,
    )
}
c
You are really not good at reading documentation, aren’t you? 😅 https://developer.android.com/kotlin/multiplatform/room#database-instantiation
c
Ha, I wrote this code previously for android platform but have forgotten.
I don't think it is my problem, but the document is really bad organized.
and once again, I have to comment these two useless lines.
Copy code
return builder
//        .addMigrations(MIGRATIONS)
//        .fallbackToDestructiveMigrationOnDowngrade()
        .setDriver(BundledSQLiteDriver())
        .setQueryCoroutineContext(<http://Dispatchers.IO|Dispatchers.IO>)
        .build()
c
Maybe at some point you will come back and uncomment then 😅 After you have asked here how to enable migration of course 😉
c
🥶