Room



Entry point for building and initializing a RoomDatabase.

Summary

Public functions

inline RoomDatabase.Builder<T>
<T : RoomDatabase> databaseBuilder(name: String, noinline factory: () -> T)

Creates a RoomDatabase.Builder for a persistent database.

android
inline RoomDatabase.Builder<T>
<T : RoomDatabase> databaseBuilder(name: String, noinline factory: () -> T)

Creates a RoomDatabase.Builder for a persistent database.

N
inline RoomDatabase.Builder<T>
<T : RoomDatabase> inMemoryDatabaseBuilder(noinline factory: () -> T)

Creates a RoomDatabase.Builder for an in memory database.

android
inline RoomDatabase.Builder<T>
<T : RoomDatabase> inMemoryDatabaseBuilder(noinline factory: () -> T)

Creates a RoomDatabase.Builder for an in memory database.

N

Public properties

String

The master table name where Room keeps its metadata information.

Cmn
android
N

Public functions

databaseBuilder

inline fun <T : RoomDatabase> databaseBuilder(
    name: String,
    noinline factory: () -> T = { findAndInstantiateDatabaseImpl(T::class.java) }
): RoomDatabase.Builder<T>

Creates a RoomDatabase.Builder for a persistent database. Once a database is built, you should keep a reference to it and re-use it.

Parameters
<T : RoomDatabase>

The type of the database class.

name: String

The name of the database file.

noinline factory: () -> T = { findAndInstantiateDatabaseImpl(T::class.java) }

An optional lambda calling RoomDatabaseConstructor.initialize corresponding to the database class of this builder. If not provided then reflection is used to find and instantiate the database implementation class.

Returns
RoomDatabase.Builder<T>

A RoomDatabaseBuilder<T> which you can use to create the database.

databaseBuilder

inline fun <T : RoomDatabase> databaseBuilder(
    name: String,
    noinline factory: () -> T = { findDatabaseConstructorAndInitDatabaseImpl(T::class) }
): RoomDatabase.Builder<T>

Creates a RoomDatabase.Builder for a persistent database. Once a database is built, you should keep a reference to it and re-use it.

Parameters
<T : RoomDatabase>

The type of the database class.

name: String

The name of the database file.

noinline factory: () -> T = { findDatabaseConstructorAndInitDatabaseImpl(T::class) }

An optional lambda calling RoomDatabaseConstructor.initialize corresponding to the database class of this builder. If not provided then the associated RoomDatabaseConstructor is searched via the ConstructedBy annotation and is used to instantiate the database implementation class.

Returns
RoomDatabase.Builder<T>

A RoomDatabaseBuilder<T> which you can use to create the database.

inMemoryDatabaseBuilder

inline fun <T : RoomDatabase> inMemoryDatabaseBuilder(
    noinline factory: () -> T = { findAndInstantiateDatabaseImpl(T::class.java) }
): RoomDatabase.Builder<T>

Creates a RoomDatabase.Builder for an in memory database. Information stored in an in memory database disappears when the process is killed. Once a database is built, you should keep a reference to it and re-use it.

Parameters
<T : RoomDatabase>

The type of the database class.

noinline factory: () -> T = { findAndInstantiateDatabaseImpl(T::class.java) }

An optional lambda calling RoomDatabaseConstructor.initialize corresponding to the database class of this builder. If not provided then reflection is used to find and instantiate the database implementation class.

Returns
RoomDatabase.Builder<T>

A RoomDatabaseBuilder<T> which you can use to create the database.

inMemoryDatabaseBuilder

inline fun <T : RoomDatabase> inMemoryDatabaseBuilder(
    noinline factory: () -> T = { findDatabaseConstructorAndInitDatabaseImpl(T::class) }
): RoomDatabase.Builder<T>

Creates a RoomDatabase.Builder for an in memory database. Information stored in an in memory database disappears when the process is killed. Once a database is built, you should keep a reference to it and re-use it.

Parameters
<T : RoomDatabase>

The type of the database class.

noinline factory: () -> T = { findDatabaseConstructorAndInitDatabaseImpl(T::class) }

An optional lambda calling RoomDatabaseConstructor.initialize corresponding to the database class of this builder. If not provided then the associated RoomDatabaseConstructor is searched via the ConstructedBy annotation and is used to instantiate the database implementation class.

Returns
RoomDatabase.Builder<T>

A RoomDatabaseBuilder<T> which you can use to create the database.

Public properties

MASTER_TABLE_NAME

val MASTER_TABLE_NAMEString

The master table name where Room keeps its metadata information.