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
RoomDatabase.Builder<T>
<T : RoomDatabase> databaseBuilder(
    context: Context,
    klass: Class<T>,
    name: String?
)

Creates a RoomDatabase.Builder for a persistent database.

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

Creates a RoomDatabase.Builder for a persistent database.

android
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
inline RoomDatabase.Builder<T>
<T : RoomDatabase> inMemoryDatabaseBuilder(
    context: Context,
    noinline factory: () -> T
)

Creates a RoomDatabase.Builder for an in memory database.

android
RoomDatabase.Builder<T>
<T : RoomDatabase> inMemoryDatabaseBuilder(context: Context, klass: Class<T>)

Creates a RoomDatabase.Builder for an in memory database.

android

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 initializeImpl() on the database class which returns the generated database implementation. 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): 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

The lambda calling initializeImpl() on the database class which returns the generated database implementation.

Returns
RoomDatabase.Builder<T>

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

databaseBuilder

fun <T : RoomDatabase> databaseBuilder(
    context: Context,
    klass: Class<T>,
    name: String?
): 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.

context: Context

The context for the database. This is usually the Application context.

klass: Class<T>

The abstract class which is annotated with Database and extends RoomDatabase.

name: String?

The name of the database file.

Returns
RoomDatabase.Builder<T>

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

databaseBuilder

inline fun <T : RoomDatabase> databaseBuilder(
    context: Context,
    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.

context: Context

The context for the database. This is usually the Application context.

name: String

The name of the database file.

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

An optional lambda calling initializeImpl() on the database class which returns the generated database implementation. 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 = { 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 initializeImpl() on the database class which returns the generated database implementation. 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): 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

The lambda calling initializeImpl() on the database class which returns the generated database implementation.

Returns
RoomDatabase.Builder<T>

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

inMemoryDatabaseBuilder

inline fun <T : RoomDatabase> inMemoryDatabaseBuilder(
    context: Context,
    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.

context: Context

The context for the database. This is usually the Application context.

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

An optional lambda calling initializeImpl() on the database class which returns the generated database implementation. 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

fun <T : RoomDatabase> inMemoryDatabaseBuilder(context: Context, klass: Class<T>): 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.

context: Context

The context for the database. This is usually the Application context.

klass: Class<T>

The abstract class which is annotated with Database and extends RoomDatabase.

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.