Android 12 Developer Preview is here! Try it out, and give us your feedback!

Builder

open class Builder<T : RoomDatabase!>
kotlin.Any
   ↳ androidx.room.RoomDatabase.Builder

Builder for RoomDatabase.

Summary

Public methods
open RoomDatabase.Builder<T>
addCallback(@NonNull callback: RoomDatabase.Callback)

Adds a Callback to this database.

open RoomDatabase.Builder<T>
addMigrations(@NonNull vararg migrations: Migration!)

Adds a migration to the builder.

open RoomDatabase.Builder<T>
addTypeConverter(@NonNull typeConverter: Any)

Adds a type converter instance to this database.

open RoomDatabase.Builder<T>

Disables the main thread query check for Room.

open T

Creates the databases and initializes it.

open RoomDatabase.Builder<T>
createFromAsset(@NonNull databaseFilePath: String)

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

open RoomDatabase.Builder<T>
createFromAsset(@NonNull databaseFilePath: String, @NonNull callback: RoomDatabase.PrepackagedDatabaseCallback)

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

open RoomDatabase.Builder<T>
createFromFile(@NonNull databaseFile: File)

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

open RoomDatabase.Builder<T>
createFromFile(@NonNull databaseFile: File, @NonNull callback: RoomDatabase.PrepackagedDatabaseCallback)

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

open RoomDatabase.Builder<T>
createFromInputStream(@NonNull inputStreamCallable: Callable<InputStream!>)

Configures Room to create and open the database using a pre-packaged database via an InputStream.

open RoomDatabase.Builder<T>
createFromInputStream(@NonNull inputStreamCallable: Callable<InputStream!>, @NonNull callback: RoomDatabase.PrepackagedDatabaseCallback)

Configures Room to create and open the database using a pre-packaged database via an InputStream.

open RoomDatabase.Builder<T>

Sets whether table invalidation in this instance of RoomDatabase should be broadcast and synchronized with other instances of the same RoomDatabase, including those in a separate process.

open RoomDatabase.Builder<T>

Allows Room to destructively recreate database tables if Migrations that would migrate old database schemas to the latest schema version are not found.

open RoomDatabase.Builder<T>
fallbackToDestructiveMigrationFrom(vararg startVersions: Int)

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

open RoomDatabase.Builder<T>

Allows Room to destructively recreate database tables if Migrations are not available when downgrading to old schema versions.

open RoomDatabase.Builder<T>

Sets the database factory.

open RoomDatabase.Builder<T>
setAutoCloseTimeout(@IntRange(0) autoCloseTimeout: Long, @NonNull autoCloseTimeUnit: TimeUnit)

Enables auto-closing for the database to free up unused resources.

open RoomDatabase.Builder<T>

Sets the journal mode for this database.

open RoomDatabase.Builder<T>
setQueryCallback(@NonNull queryCallback: RoomDatabase.QueryCallback, @NonNull executor: Executor)

Sets a QueryCallback to be invoked when queries are executed.

open RoomDatabase.Builder<T>
setQueryExecutor(@NonNull executor: Executor)

Sets the Executor that will be used to execute all non-blocking asynchronous queries and tasks, including LiveData invalidation, Flowable scheduling and ListenableFuture tasks.

open RoomDatabase.Builder<T>
setTransactionExecutor(@NonNull executor: Executor)

Sets the Executor that will be used to execute all non-blocking asynchronous transaction queries and tasks, including LiveData invalidation, Flowable scheduling and ListenableFuture tasks.

Public methods

addCallback

@NonNull open fun addCallback(@NonNull callback: RoomDatabase.Callback): RoomDatabase.Bui