# SQLiteDriver

Artifact: [androidx.sqlite:sqlite](https://developer.android.com/jetpack/androidx/releases/sqlite) [View Source](https://cs.android.com/search?q=file:androidx/sqlite/SQLiteDriver.+class:androidx.sqlite.SQLiteDriver) Added in [2.5.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.5.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  interface SQLiteDriver
  ```
Known direct subclasses [AndroidSQLiteDriver](https://developer.android.com/reference/kotlin/androidx/sqlite/driver/AndroidSQLiteDriver), [BundledSQLiteDriver](https://developer.android.com/reference/kotlin/androidx/sqlite/driver/bundled/BundledSQLiteDriver), [NativeSQLiteDriver](https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver), [SupportSQLiteDriver](https://developer.android.com/reference/kotlin/androidx/sqlite/driver/SupportSQLiteDriver), [WebWorkerSQLiteDriver](https://developer.android.com/reference/kotlin/androidx/sqlite/driver/web/WebWorkerSQLiteDriver)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/AndroidSQLiteDriver` | A `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` implemented by `https://developer.android.com/reference/android/database/package-summary.html` and that uses the Android's SDK SQLite APIs. |
| `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/bundled/BundledSQLiteDriver` | A `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` that uses a bundled version of SQLite included as a native component of this library. |
| `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver` | A `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` that uses a version of SQLite included with the host operating system. |
| `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/SupportSQLiteDriver` | A `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` implemented by `https://developer.android.com/reference/kotlin/androidx/sqlite/db/SupportSQLiteOpenHelper` and that uses the Android's SQLite through the `SupportSQLite` APIs. |
| `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/web/WebWorkerSQLiteDriver` | A `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` that communicates with a web worker delegating database operations to the web worker. |

*** ** * ** ***

An interface to open database connections.

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection` | `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#open(kotlin.String)(fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Opens a new database connection. | Cmn |
| `suspend https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection` | `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#open(kotlin.String)(fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Opens a new database connection asynchronously. | JS |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#hasConnectionPool()` Identifies whether the driver has an internal connection pool or not. | Cmn JS |

| ### Extension functions |
|---|---|---|
| `suspend https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection` | `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver.https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#(androidx.sqlite.SQLiteDriver).open(kotlin.String)(fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Opens a new database connection. | Cmn JS |

## Public functions

### open

Cmn Added in [2.5.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.5.0)

```
fun open(fileName: String): SQLiteConnection
```

Opens a new database connection.

To open an in-memory database use the special name `:memory:` as the `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#open(kotlin.String)`.

| Parameters |
|---|---|
| `fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Name of the database file. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection` | the database connection. |

### open

JS

```
suspend fun open(fileName: String): SQLiteConnection
```

Opens a new database connection asynchronously.

To open an in-memory database use the special name `:memory:` as the `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#open(kotlin.String)`.

| Parameters |
|---|---|
| `fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Name of the database file. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection` | the database connection. |

## Public properties

### hasConnectionPool

Cmn JS Added in [2.6.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.6.0)

```
val hasConnectionPool: Boolean
```

Identifies whether the driver has an internal connection pool or not.

A driver with an internal pool should be capable of opening connections that are safe to be used in a multi-thread and concurrent environment whereas a driver that does not have an internal pool will require the application to manage connections in a thread-safe manner. A driver might not report containing a connection pool but might still be safe to be used in a multi-thread environment, such behavior will depend on the driver implementation.

The value returned should be used as a signal to higher abstractions in order to determine if the driver and its connections should be managed by an external connection pool or not.

## Extension functions

### SQLiteDriver.open

Cmn JS Artifact: [androidx.sqlite:sqlite-async](https://developer.android.com/jetpack/androidx/releases/sqlite) [View Source](https://cs.android.com/search?q=file:androidx/sqlite/async/SQLiteAsync.+function:open)

```
suspend fun SQLiteDriver.open(fileName: String): SQLiteConnection
```

Opens a new database connection.

On web targets this function is asynchronous while for non-web it is synchronous.