Room

object Room


Utility functions for Room.

Summary

Constants

const String

The master table where room keeps its metadata information.

Public functions

RoomDatabase.Builder<T>
<T : RoomDatabase> databaseBuilder(
    context: Context,
    klass: Class<T>,
    name: String?
)

Creates a RoomDatabase.Builder for a persistent database.

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

Creates a RoomDatabase.Builder for an in memory database.

Constants

MASTER_TABLE_NAME

Added in 2.0.0
const val MASTER_TABLE_NAMEString

The master table where room keeps its metadata information.

Public functions

databaseBuilder

Added in 2.0.0
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.

inMemoryDatabaseBuilder

Added in 2.0.0
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.