# NativeSQLiteDriver

Artifact: [androidx.sqlite:sqlite-framework](https://developer.android.com/jetpack/androidx/releases/sqlite) [View Source](https://cs.android.com/search?q=file:androidx/sqlite/driver/NativeSQLiteDriver.kt+class:androidx.sqlite.driver.NativeSQLiteDriver) Android/JVMNative/C/iOS
- N

  ```
  class NativeSQLiteDriver : SQLiteDriver
  ```

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` that uses a version of SQLite included with the host operating system.

Usage of this driver expects that `libsqlite` can be found in the shared library path.

The host's SQLite used by this driver might be compiled with different [threading modes](https://www.sqlite.org/threadsafe.html) which can be checked with `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#threadingMode()`. Regardless of the mode compiled, this driver does not have an internal connection pool and whether the driver connections are thread-safe or not will be determined by the compiled threading mode of the host library.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#NativeSQLiteDriver()()` | N |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#addExtension(kotlin.String)(fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Registers a dynamically-linked SQLite extension to load for every subsequent connection opened with this driver. | N |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#addExtension(kotlin.String,kotlin.String)(fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, entryPoint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Registers a dynamically-linked SQLite extension to load for every subsequent connection opened with this driver. | N |
| `open https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection` | `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#open(kotlin.String)(fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Opens a new database connection. | N |
| `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteConnection` | `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#open(kotlin.String,kotlin.Int)(fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Opens a new database connection. | N |

### Inherited properties

From [androidx.sqlite.SQLiteDriver](https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver) `open 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.
N

## Public constructors

### NativeSQLiteDriver

N

```
NativeSQLiteDriver()
```

## Public functions

### addExtension

N

```
fun addExtension(fileName: String): Unit
```

Registers a dynamically-linked SQLite extension to load for every subsequent connection opened with this driver.

The extension is loaded by SQLite in a platform-specific way. SQLite will attempt to open the file using (e.g. dlopen on POSIX) and look up a native function responsible for initializing the extension. SQLite will derive the entry function from the file name.

It is the developer's responsibility to ensure that the library is actually available with the app. If the file is not available when a connection from this driver is opened, then an `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteException` will be thrown during `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#open(kotlin.String)`.

See also: [Load an extension](https://www.sqlite.org/c3ref/load_extension.html)

| Parameters |
|---|---|
| `fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The path to the extension to load. A given file can only be added as an extension once. |

### addExtension

N

```
fun addExtension(fileName: String, entryPoint: String): Unit
```

Registers a dynamically-linked SQLite extension to load for every subsequent connection opened with this driver.

The extension is loaded by SQLite in a platform-specific way. SQLite will attempt to open the file using (e.g. dlopen on POSIX) and look up a native function responsible for initializing the extension. The `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#addExtension(kotlin.String,kotlin.String)` defines the function name to be invoke to initialize the extension.

It is the developer's responsibility to ensure that the library is actually available with the app. If the file is not available when a connection from this driver is opened, then an `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteException` will be thrown during `https://developer.android.com/reference/kotlin/androidx/sqlite/driver/NativeSQLiteDriver#open(kotlin.String)`.

See also: [Load an extension](https://www.sqlite.org/c3ref/load_extension.html)

| Parameters |
|---|---|
| `fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The path to the extension to load. A given file can only be added as an extension once. |
| `entryPoint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The function name to serve as entry point in the loaded extension library. |

### open

N

```
open 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

N

```
fun open(fileName: String, flags: Int): SQLiteConnection
```

Opens a new database connection.

See also [Opening A New Database Connection](https://www.sqlite.org/c3ref/open.html)

| Parameters |
|---|---|
| `fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Name of the database file. |
| `flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Connection open flags. Value is either `0` or a combination of the following: - `1` - `2` - `4` - `64` - `128` - `32768` - `65536` - `16777216` - `33554432` <br /> |

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