All Downloads are FREE. Search and download functionalities are using the official Maven repository.

androidMain.com.ditchoom.mqtt3.persistence.SqlDriver.kt Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package com.ditchoom.mqtt3.persistence

import android.content.Context
import app.cash.sqldelight.db.SqlDriver
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver
import com.ditchoom.Mqtt4

actual fun sqlDriver(androidContext: Any?, name: String, inMemory: Boolean): SqlDriver? = if (androidContext != null) {
    AndroidSqliteDriver(
        Mqtt4.Schema,
        androidContext as Context,
        if (inMemory) {
            null
        } else {
            name
        }
    )
} else {
    val driver = JdbcSqliteDriver(
        if (inMemory) {
            JdbcSqliteDriver.IN_MEMORY
        } else {
            name
        }
    )
    Mqtt4.Schema.create(driver)
    driver
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy