I’m experimenting with Exposed in Android, I was a...
# exposed
m
I’m experimenting with Exposed in Android, I was able to use it with H2 DB. But I’m facing an issue that I don’t see any data in UI. After debugging for a while I noticed that the DB was closed. It was told in docs that
DB_CLOSE_DELAY=-1
is required to keep the H2 DB open. I followed the same but no luck. This is how I’m creating
Copy code
private fun Scope.getDbPath(): String = File(androidContext().dataDir, "databases").absolutePath

private fun create(dataDirPath: String): Database = Database.connect(
    url = "jdbc:h2:$dataDirPath/database;DB_CLOSE_DELAY=-1",
    driver = "org.h2.Driver",
    setupConnection = { connection ->
        connection.autoCommit = true
        connection.transactionIsolation = Connection.TRANSACTION_REPEATABLE_READ
    }
)