# RoomDatabase.Builder

Artifact: [androidx.room3:room3-runtime](https://developer.android.com/jetpack/androidx/releases/room3) [View Source](https://cs.android.com/search?q=file:androidx/room3/RoomDatabase.+class:androidx.room3.RoomDatabase.Builder) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  class RoomDatabase.Builder<T : RoomDatabase>
  ```

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase`.

| Parameters |
|---|---|
| `<T : https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase>` | The type of the abstract database class. |

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#addAutoMigrationSpec(androidx.room3.migration.AutoMigrationSpec)(autoMigrationSpec: https://developer.android.com/reference/kotlin/androidx/room3/migration/AutoMigrationSpec)` Adds an auto migration spec instance to the builder. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#addCallback(androidx.room3.RoomDatabase.Callback)(callback: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback)` Adds a `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback` to this database. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#addColumnTypeConverter(kotlin.Any)(typeConverter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)` Adds a column type converter instance to the builder. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#addDaoReturnTypeConverter(kotlin.Any)(daoReturnTypeConverter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)` Adds a DAO return type converter instance to the builder. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#addMigrations(kotlin.Array)(vararg migrations: https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration)` Adds a migration to the builder. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#allowDataLossOnRecovery(kotlin.Boolean)(allowDataLossOnRecovery: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether Room is allowed to delete and recreate the database file during corruption recovery. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#allowMainThreadQueries()()` Disables the main thread query check for Room. | android |
| `T` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#build()()` Creates the database and initializes it. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#createFromAsset(kotlin.String)(databaseFilePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Configures Room to create and open the database using a pre-packaged database located in the application 'assets/' folder. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#createFromAsset(kotlin.String,androidx.room3.RoomDatabase.PrepackagedDatabaseCallback)( databaseFilePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, callback: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.PrepackagedDatabaseCallback )` Configures Room to create and open the database using a pre-packaged database located in the application 'assets/' folder. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#createFromFile(java.io.File)(databaseFile: https://developer.android.com/reference/java/io/File.html)` Configures Room to create and open the database using a pre-packaged database file. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#createFromFile(java.io.File,androidx.room3.RoomDatabase.PrepackagedDatabaseCallback)( databaseFile: https://developer.android.com/reference/java/io/File.html, callback: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.PrepackagedDatabaseCallback )` Configures Room to create and open the database using a pre-packaged database file. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#createFromInputStream(java.util.concurrent.Callable)(inputStreamCallable: https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/io/InputStream.html>)` Configures Room to create and open the database using a pre-packaged database via an `https://developer.android.com/reference/java/io/InputStream.html`. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#createFromInputStream(java.util.concurrent.Callable,androidx.room3.RoomDatabase.PrepackagedDatabaseCallback)( inputStreamCallable: https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/io/InputStream.html>, callback: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.PrepackagedDatabaseCallback )` Configures Room to create and open the database using a pre-packaged database via an `https://developer.android.com/reference/java/io/InputStream.html`. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#enableMultiInstanceInvalidation()()` Sets whether table invalidation in this instance of `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase` should be broadcast and synchronized with other instances of the same `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase`, including those in a separate process. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#fallbackToDestructiveMigration(kotlin.Boolean)(dropAllTables: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Allows Room to destructively recreate database tables if `https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration`s that would migrate old database schemas to the latest schema version are not found. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#fallbackToDestructiveMigrationFrom(kotlin.Boolean,kotlin.IntArray)( dropAllTables: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, vararg startVersions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Informs Room that it is allowed to destructively recreate database tables from specific starting schema versions. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#fallbackToDestructiveMigrationOnDowngrade(kotlin.Boolean)(dropAllTables: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Allows Room to destructively recreate database tables if `https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration`s are not available when downgrading to old schema versions. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `@https://developer.android.com/reference/kotlin/androidx/room3/ExperimentalRoomApi https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setAutoCloseTimeout(kotlin.Long,java.util.concurrent.TimeUnit)( autoCloseTimeout: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, autoCloseTimeUnit: https://developer.android.com/reference/java/util/concurrent/TimeUnit.html )` Enables auto-closing for the database to free up unused resources. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setConnectionPoolTimeout(kotlin.time.Duration)(timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html)` Sets the timeout `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html` to wait when acquiring a connection from the before timing out and throwing an `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteException`. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setDriver(androidx.sqlite.SQLiteDriver)(driver: https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver)` Sets the `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` implementation to be used by Room to open database connections. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `@https://developer.android.com/reference/kotlin/androidx/room3/ExperimentalRoomApi https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setInMemoryTrackingMode(kotlin.Boolean)(inMemory: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether Room will use an in-memory table or a persisted table to track invalidation. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setJournalMode(androidx.room3.RoomDatabase.JournalMode)(journalMode: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode)` Sets the journal mode for this database. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `@https://developer.android.com/reference/kotlin/androidx/room3/ExperimentalRoomApi https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setMultiInstanceInvalidationServiceIntent(android.content.Intent)( invalidationServiceIntent: https://developer.android.com/reference/android/content/Intent.html )` Sets whether table invalidation in this instance of `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase` should be broadcast and synchronized with other instances of the same `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase`, including those in a separate process. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setMultipleConnectionPool(kotlin.Int,kotlin.Int)(maxNumOfReaders: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxNumOfWriters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the database connection pool to use multiple connections, separating readers and writers. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `@https://developer.android.com/reference/kotlin/androidx/room3/ExperimentalRoomApi https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setPreparedStatementCacheSize(kotlin.Int)(maxCacheSize: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the maximum number of prepared statements cached per database connection. | android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setQueryCoroutineContext(kotlin.coroutines.CoroutineContext)(context: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html)` Sets the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` that will be used to execute all asynchronous queries and tasks, such as `Flow` emissions and `https://developer.android.com/reference/kotlin/androidx/room3/InvalidationTracker` notifications. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setSingleConnectionPool()()` Sets the database connection pool to use a single connection for both reading and writing. | Cmn android |

## Public functions

### addAutoMigrationSpec

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

```
fun addAutoMigrationSpec(autoMigrationSpec: AutoMigrationSpec): RoomDatabase.Builder<T>
```

Adds an auto migration spec instance to the builder.

| Parameters |
|---|---|
| `autoMigrationSpec: https://developer.android.com/reference/kotlin/androidx/room3/migration/AutoMigrationSpec` | The auto migration object that is annotated with `https://developer.android.com/reference/kotlin/androidx/room3/ProvidedAutoMigrationSpec` and is declared in an `https://developer.android.com/reference/kotlin/androidx/room3/AutoMigration` annotation. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### addCallback

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

```
fun addCallback(callback: RoomDatabase.Callback): RoomDatabase.Builder<T>
```

Adds a `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback` to this database.

| Parameters |
|---|---|
| `callback: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback` | The callback. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### addColumnTypeConverter

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

```
fun addColumnTypeConverter(typeConverter: Any): RoomDatabase.Builder<T>
```

Adds a column type converter instance to the builder.

| Parameters |
|---|---|
| `typeConverter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html` | The converter instance that is annotated with `https://developer.android.com/reference/kotlin/androidx/room3/ProvidedColumnTypeConverter`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### addDaoReturnTypeConverter

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

```
fun addDaoReturnTypeConverter(daoReturnTypeConverter: Any): RoomDatabase.Builder<T>
```

Adds a DAO return type converter instance to the builder.

| Parameters |
|---|---|
| `daoReturnTypeConverter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html` | The converter instance that is annotated with `https://developer.android.com/reference/kotlin/androidx/room3/ProvidedDaoReturnTypeConverter`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### addMigrations

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

```
fun addMigrations(vararg migrations: Migration): RoomDatabase.Builder<T>
```

Adds a migration to the builder.

Each `https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration` has a start and end versions and Room runs these migrations to bring the database to the latest version.

A migration can handle more than 1 version (e.g. if you have a faster path to choose when going from version 3 to 5 without going to version 4). If Room opens a database at version 3 and latest version is \>= 5, Room will use the migration object that can migrate from 3 to 5 instead of 3 to 4 and 4 to 5.

| Parameters |
|---|---|
| `vararg migrations: https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration` | The migration objects that modify the database schema with the necessary changes for a version change. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### allowDataLossOnRecovery

Cmn android Added in [3.1.0-alpha03](https://developer.android.com/jetpack/androidx/releases/room3#3.1.0-alpha03)

```
fun allowDataLossOnRecovery(allowDataLossOnRecovery: Boolean = true): RoomDatabase.Builder<T>
```

Sets whether Room is allowed to delete and recreate the database file during corruption recovery.

During initialization, Room attempts to open and verify the database connection. If opening fails due to an `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteException` (such as file corruption) and cannot be resolved by an initial retry, Room enters a recovery flow:

- If `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#allowDataLossOnRecovery(kotlin.Boolean)` is `true`, Room deletes the corrupted database file along with any companion journal files (`-wal`, `-shm`, `-journal`) and recreates the database, resulting in data loss.

- If `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#allowDataLossOnRecovery(kotlin.Boolean)` is `false` (the default), Room rethrows the exception without attempting recovery.

| Parameters |
|---|---|
| `allowDataLossOnRecovery: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | whether database deletion and recreation is permitted on corruption |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | this builder instance |

### allowMainThreadQueries

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
fun allowMainThreadQueries(): RoomDatabase.Builder<T>
```

Disables the main thread query check for Room.

Room ensures that Database is never accessed on the main thread because it may lock the main thread and trigger an ANR. If you need to access the database from the main thread, you should always use async alternatives or manually move the call to a background thread.

You may want to turn this check off for testing.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### build

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

```
fun build(): T
```

Creates the database and initializes it.

| Returns |
|---|---|
| `T` | A new database instance. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the builder was misconfigured. |

### createFromAsset

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
fun createFromAsset(databaseFilePath: String): RoomDatabase.Builder<T>
```

Configures Room to create and open the database using a pre-packaged database located in the application 'assets/' folder.

Room does not open the pre-packaged database, instead it copies it into the internal app database folder and then opens it. The pre-packaged database file must be located in the "assets/" folder of your application. For example, the path for a file located in "assets/databases/products.db" would be "databases/products.db".

The pre-packaged database schema will be validated. It might be best to create your pre-packaged database schema utilizing the exported schema files generated when `https://developer.android.com/reference/kotlin/androidx/room3/Database#exportSchema()` is enabled.

This method is not supported for an in memory database `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder`.

| Parameters |
|---|---|
| `databaseFilePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The file path within the 'assets/' directory of where the database file is located. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### createFromAsset

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
fun createFromAsset(
    databaseFilePath: String,
    callback: RoomDatabase.PrepackagedDatabaseCallback
): RoomDatabase.Builder<T>
```

Configures Room to create and open the database using a pre-packaged database located in the application 'assets/' folder.

Room does not open the pre-packaged database, instead it copies it into the internal app database folder and then opens it. The pre-packaged database file must be located in the "assets/" folder of your application. For example, the path for a file located in "assets/databases/products.db" would be "databases/products.db".

The pre-packaged database schema will be validated. It might be best to create your pre-packaged database schema utilizing the exported schema files generated when `https://developer.android.com/reference/kotlin/androidx/room3/Database#exportSchema()` is enabled.

This method is not supported for an in memory database `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder` and a `https://developer.android.com/reference/android/content/Context.html` is required during builder instantiation.

| Parameters |
|---|---|
| `databaseFilePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The file path within the 'assets/' directory of where the database file is located. |
| `callback: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.PrepackagedDatabaseCallback` | The pre-packaged callback. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### createFromFile

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
fun createFromFile(databaseFile: File): RoomDatabase.Builder<T>
```

Configures Room to create and open the database using a pre-packaged database file.

Room does not open the pre-packaged database, instead it copies it into the internal app database folder and then opens it. The given file must be accessible and the right permissions must be granted for Room to copy the file.

The pre-packaged database schema will be validated. It might be best to create your pre-packaged database schema utilizing the exported schema files generated when `https://developer.android.com/reference/kotlin/androidx/room3/Database#exportSchema()` is enabled.

The `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback#onOpen(androidx.sqlite.SQLiteConnection)` method can be used as an indicator that the pre-packaged database was successfully opened by Room and can be cleaned up.

This method is not supported for an in memory database `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder`.

| Parameters |
|---|---|
| `databaseFile: https://developer.android.com/reference/java/io/File.html` | The database file. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### createFromFile

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
fun createFromFile(
    databaseFile: File,
    callback: RoomDatabase.PrepackagedDatabaseCallback
): RoomDatabase.Builder<T>
```

Configures Room to create and open the database using a pre-packaged database file.

Room does not open the pre-packaged database, instead it copies it into the internal app database folder and then opens it. The given file must be accessible and the right permissions must be granted for Room to copy the file.

The pre-packaged database schema will be validated. It might be best to create your pre-packaged database schema utilizing the exported schema files generated when `https://developer.android.com/reference/kotlin/androidx/room3/Database#exportSchema()` is enabled.

The `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback#onOpen(androidx.sqlite.SQLiteConnection)` method can be used as an indicator that the pre-packaged database was successfully opened by Room and can be cleaned up.

This method is not supported for an in memory database `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder` and a `https://developer.android.com/reference/android/content/Context.html` is required during builder instantiation.

| Parameters |
|---|---|
| `databaseFile: https://developer.android.com/reference/java/io/File.html` | The database file. |
| `callback: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.PrepackagedDatabaseCallback` | The pre-packaged callback. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### createFromInputStream

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
fun createFromInputStream(inputStreamCallable: Callable<InputStream>): RoomDatabase.Builder<T>
```

Configures Room to create and open the database using a pre-packaged database via an `https://developer.android.com/reference/java/io/InputStream.html`.

This is useful for processing compressed database files. Room does not open the pre-packaged database, instead it copies it into the internal app database folder, and then open it. The `https://developer.android.com/reference/java/io/InputStream.html` will be closed once Room is done consuming it.

The pre-packaged database schema will be validated. It might be best to create your pre-packaged database schema utilizing the exported schema files generated when `https://developer.android.com/reference/kotlin/androidx/room3/Database#exportSchema()` is enabled.

The `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback#onOpen(androidx.sqlite.SQLiteConnection)` method can be used as an indicator that the pre-packaged database was successfully opened by Room and can be cleaned up.

This method is not supported for an in memory database `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder` and a `https://developer.android.com/reference/android/content/Context.html` is required during builder instantiation.

| Parameters |
|---|---|
| `inputStreamCallable: https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/io/InputStream.html>` | A callable that returns an InputStream from which to copy the database. The callable will be invoked in a thread from the dispatcher set via `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setQueryCoroutineContext(kotlin.coroutines.CoroutineContext)`. The callable is only invoked if Room needs to create and open the database from the pre-package database, usually the first time it is created or during a destructive migration. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### createFromInputStream

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
fun createFromInputStream(
    inputStreamCallable: Callable<InputStream>,
    callback: RoomDatabase.PrepackagedDatabaseCallback
): RoomDatabase.Builder<T>
```

Configures Room to create and open the database using a pre-packaged database via an `https://developer.android.com/reference/java/io/InputStream.html`.

This is useful for processing compressed database files. Room does not open the pre-packaged database, instead it copies it into the internal app database folder, and then open it. The `https://developer.android.com/reference/java/io/InputStream.html` will be closed once Room is done consuming it.

The pre-packaged database schema will be validated. It might be best to create your pre-packaged database schema utilizing the exported schema files generated when `https://developer.android.com/reference/kotlin/androidx/room3/Database#exportSchema()` is enabled.

The `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback#onOpen(androidx.sqlite.SQLiteConnection)` method can be used as an indicator that the pre-packaged database was successfully opened by Room and can be cleaned up.

This method is not supported for an in memory database `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder`.

| Parameters |
|---|---|
| `inputStreamCallable: https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/io/InputStream.html>` | A callable that returns an InputStream from which to copy the database. The callable will be invoked in a thread from the dispatcher set via `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setQueryCoroutineContext(kotlin.coroutines.CoroutineContext)`. The callable is only invoked if Room needs to create and open the database from the pre-package database, usually the first time it is created or during a destructive migration. |
| `callback: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.PrepackagedDatabaseCallback` | The pre-packaged callback. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### enableMultiInstanceInvalidation

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
fun enableMultiInstanceInvalidation(): RoomDatabase.Builder<T>
```

Sets whether table invalidation in this instance of `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase` should be broadcast and synchronized with other instances of the same `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase`, including those in a separate process. In order to enable multi-instance invalidation, this has to be turned on both ends.

This is not enabled by default.

This does not work for in-memory databases. This does not work between database instances targeting different database files.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### fallbackToDestructiveMigration

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

```
fun fallbackToDestructiveMigration(dropAllTables: Boolean = true): RoomDatabase.Builder<T>
```

Allows Room to destructively recreate database tables if `https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration`s that would migrate old database schemas to the latest schema version are not found.

When the database version on the device does not match the latest schema version, Room runs necessary `https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration`s on the database. If it cannot find the set of `https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration`s that will bring the database to the current version, it will throw an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html`. You can call this method to change this behavior to re-create the database tables instead of crashing.

To let Room fallback to destructive migration only during a schema downgrade then use `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#fallbackToDestructiveMigrationOnDowngrade(kotlin.Boolean)`.

| Parameters |
|---|---|
| `dropAllTables: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | Set to `true` if all tables should be dropped during destructive migration including those not managed by Room, otherwise only Room managed tables are dropped. Default value is `true` as otherwise Room could leave obsolete data when table names or existence changes between versions. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### fallbackToDestructiveMigrationFrom

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

```
fun fallbackToDestructiveMigrationFrom(
    dropAllTables: Boolean = true,
    vararg startVersions: Int
): RoomDatabase.Builder<T>
```

Informs Room that it is allowed to destructively recreate database tables from specific starting schema versions.

This functionality is the same `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#fallbackToDestructiveMigration(kotlin.Boolean)`, except that this method allows the specification of a set of schema versions for which destructive recreation is allowed.

Using this method is preferable to `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#fallbackToDestructiveMigration(kotlin.Boolean)` if you want to allow destructive migrations from some schema versions while still taking advantage of exceptions being thrown due to unintentionally missing migrations.

Note: No versions passed to this method may also exist as either starting or ending versions in the `https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration`s provided via `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#addMigrations(kotlin.Array)`. If a version passed to this method is found as a starting or ending version in a Migration, an exception will be thrown.

| Parameters |
|---|---|
| `dropAllTables: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | Set to `true` if all tables should be dropped during destructive migration including those not managed by Room, otherwise only Room managed tables are dropped. Default value is `true` as otherwise Room could leave obsolete data when table names or existence changes between versions. |
| `vararg startVersions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The set of schema versions from which Room should use a destructive migration. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### fallbackToDestructiveMigrationOnDowngrade

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

```
fun fallbackToDestructiveMigrationOnDowngrade(dropAllTables: Boolean = true): RoomDatabase.Builder<T>
```

Allows Room to destructively recreate database tables if `https://developer.android.com/reference/kotlin/androidx/room3/migration/Migration`s are not available when downgrading to old schema versions.

For details, see `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#fallbackToDestructiveMigration(kotlin.Boolean)`.

| Parameters |
|---|---|
| `dropAllTables: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | Set to `true` if all tables should be dropped during destructive migration including those not managed by Room, otherwise only Room managed tables are dropped. Default value is `true` as otherwise Room could leave obsolete data when table names or existence changes between versions. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### setAutoCloseTimeout

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
@ExperimentalRoomApi
fun setAutoCloseTimeout(
    autoCloseTimeout: @IntRange(from = 0) Long,
    autoCloseTimeUnit: TimeUnit
): RoomDatabase.Builder<T>
```

Enables auto-closing for the database to free up unused resources. The underlying database will be closed after it's last use after the specified `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setAutoCloseTimeout(kotlin.Long,java.util.concurrent.TimeUnit)` has elapsed since its last usage. The database will be automatically re-opened the next time it is accessed.

Auto-closing is not compatible with in-memory databases since the data will be lost when the database is auto-closed.

Also, temp tables and temp triggers will be cleared each time the database is auto-closed. If you need to use them, please include them in your callback `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback#onOpen(androidx.sqlite.SQLiteConnection)`.

All configuration should happen in your `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback#onOpen(androidx.sqlite.SQLiteConnection)` callback so it is re-applied every time the database is re-opened. Note that the `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Callback#onOpen(androidx.sqlite.SQLiteConnection)` will be called every time the database is re-opened.

The auto-closing database operation runs on the query executor.

The database will not be re-opened if the RoomDatabase is closed manually (by calling `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase#close()`). If the database is closed manually, you must create a new database using `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#build()`.

| Parameters |
|---|---|
| `autoCloseTimeout: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the amount of time after the last usage before closing the database. Must greater or equal to zero. |
| `autoCloseTimeUnit: https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` | the timeunit for autoCloseTimeout. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### setConnectionPoolTimeout

Cmn android Added in [3.1.0-alpha03](https://developer.android.com/jetpack/androidx/releases/room3#3.1.0-alpha03)

```
fun setConnectionPoolTimeout(timeout: Duration): RoomDatabase.Builder<T>
```

Sets the timeout `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html` to wait when acquiring a connection from the before timing out and throwing an `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteException`.

Defaults to `30.seconds`.

| Parameters |
|---|---|
| `timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html` | The maximum duration to wait for a connection. Must be positive. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setConnectionPoolTimeout(kotlin.time.Duration)` is not positive. |

### setDriver

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

```
fun setDriver(driver: SQLiteDriver): RoomDatabase.Builder<T>
```

Sets the `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` implementation to be used by Room to open database connections.

| Parameters |
|---|---|
| `driver: https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` | The driver |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### setInMemoryTrackingMode

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
@ExperimentalRoomApi
fun setInMemoryTrackingMode(inMemory: Boolean): RoomDatabase.Builder<T>
```

Sets whether Room will use an in-memory table or a persisted table to track invalidation.

An in-memory table is used by default. Using an in-memory tables is more performant, reduces the journal file size but has an increased memory footprint, where as using a real table has the opposite effect.

| Parameters |
|---|---|
| `inMemory: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if in-memory tables should be used, false otherwise. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder` instance |

### setJournalMode

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

```
fun setJournalMode(journalMode: RoomDatabase.JournalMode): RoomDatabase.Builder<T>
```

Sets the journal mode for this database.

The value is ignored if the builder is for an 'in-memory database'. The journal mode should be consistent across multiple instances of `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase` for a single SQLite database file.

The default value is `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode#WRITE_AHEAD_LOGGING`.

| Parameters |
|---|---|
| `journalMode: https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode` | The journal mode. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### setMultiInstanceInvalidationServiceIntent

android Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
@ExperimentalRoomApi
fun setMultiInstanceInvalidationServiceIntent(
    invalidationServiceIntent: Intent
): RoomDatabase.Builder<T>
```

Sets whether table invalidation in this instance of `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase` should be broadcast and synchronized with other instances of the same `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase`, including those in a separate process. In order to enable multi-instance invalidation, this has to be turned on both ends and need to point to the same `https://developer.android.com/reference/kotlin/androidx/room3/MultiInstanceInvalidationService`.

This is not enabled by default and requires that a `https://developer.android.com/reference/android/content/Context.html` is used during builder instantiation.

This does not work for in-memory databases. This does not work between database instances targeting different database files.

| Parameters |
|---|---|
| `invalidationServiceIntent: https://developer.android.com/reference/android/content/Intent.html` | Intent to bind to the `https://developer.android.com/reference/kotlin/androidx/room3/MultiInstanceInvalidationService`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

### setMultipleConnectionPool

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

```
fun setMultipleConnectionPool(maxNumOfReaders: Int, maxNumOfWriters: Int): RoomDatabase.Builder<T>
```

Sets the database connection pool to use multiple connections, separating readers and writers.

A connection pool is only used if the supplied `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` has no internal pool, i.e. `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#hasConnectionPool()` returns `false`. If the configured driver has an internal pool then calling this function has no effect.

If the database being built is an in-memory database, then calling this function has no effect since a single connection will be used.

Calling this function overrides any previous setting. If neither this function or `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setMultipleConnectionPool(kotlin.Int,kotlin.Int)` are called then Room will default to a connection pool configuration that is based on the `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode`. For `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode#TRUNCATE` a single connection is used, while for `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode#WRITE_AHEAD_LOGGING` multiple connections are used, four reader and one writer.

It is recommended to only use multiple connections when `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode#WRITE_AHEAD_LOGGING` is configured. Be aware that if multiple writers are used then database operations might fail with `SQLITE_BUSY` errors. These must be handled by the callers and might be mitigated by configuring the `busy_timeout`.

| Parameters |
|---|---|
| `maxNumOfReaders: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of reader connections. |
| `maxNumOfWriters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of writer connections. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setSingleConnectionPool()` |   |

### setPreparedStatementCacheSize

android Added in [3.1.0-alpha03](https://developer.android.com/jetpack/androidx/releases/room3#3.1.0-alpha03)

```
@ExperimentalRoomApi
fun setPreparedStatementCacheSize(maxCacheSize: @IntRange(from = 0) Int): RoomDatabase.Builder<T>
```

Sets the maximum number of prepared statements cached per database connection.

The statement cache is only used if the supplied `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` has no internal pool, i.e., `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#hasConnectionPool()` returns `false`. If the configured driver has an internal pool then calling this function has no effect.

Defaults to `25`. Setting `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setPreparedStatementCacheSize(kotlin.Int)` to `0` disables the cache.

| Parameters |
|---|---|
| `maxCacheSize: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of prepared statements to cache per connection. Must be non-negative. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setPreparedStatementCacheSize(kotlin.Int)` is negative. |

### setQueryCoroutineContext

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

```
fun setQueryCoroutineContext(context: CoroutineContext): RoomDatabase.Builder<T>
```

Sets the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` that will be used to execute all asynchronous queries and tasks, such as `Flow` emissions and `https://developer.android.com/reference/kotlin/androidx/room3/InvalidationTracker` notifications.

If no `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` is present in the `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setQueryCoroutineContext(kotlin.coroutines.CoroutineContext)` then this function will throw an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html`

| Parameters |
|---|---|
| `context: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` | The context |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder` instance |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setQueryCoroutineContext(kotlin.coroutines.CoroutineContext)` has no `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` |

### setSingleConnectionPool

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

```
fun setSingleConnectionPool(): RoomDatabase.Builder<T>
```

Sets the database connection pool to use a single connection for both reading and writing.

A connection pool is only used if the supplied `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver` has no internal pool, i.e. `https://developer.android.com/reference/kotlin/androidx/sqlite/SQLiteDriver#hasConnectionPool()` returns `false`. If the configured driver has an internal pool then calling this function has no effect.

Calling this function overrides any previous setting.If neither this function or `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setMultipleConnectionPool(kotlin.Int,kotlin.Int)` are called then Room will default to a connection pool configuration that is based on the `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode`. For `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode#TRUNCATE` a single connection is used, while for `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.JournalMode#WRITE_AHEAD_LOGGING` multiple connections are used, four reader and one writer.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder<T>` | This builder instance. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/RoomDatabase.Builder#setMultipleConnectionPool(kotlin.Int,kotlin.Int)` |   |