Room
open class Room
kotlin.Any | |
↳ | androidx.room.Room |
Utility class for Room.
Summary
Constants | |
---|---|
static String |
The master table where room keeps its metadata information. |
Public constructors | |
---|---|
<init>() |
Public methods | |
---|---|
open static RoomDatabase.Builder<T> |
databaseBuilder(@NonNull context: Context, @NonNull klass: Class<T>, @NonNull name: String) Creates a RoomDatabase. |
open static RoomDatabase.Builder<T> |
inMemoryDatabaseBuilder(@NonNull context: Context, @NonNull klass: Class<T>) Creates a RoomDatabase. |
Constants
MASTER_TABLE_NAME
static val MASTER_TABLE_NAME: String
The master table where room keeps its metadata information.
Value: RoomMasterTable.TABLE_NAME
Public constructors
<init>
Room()
Deprecated: This type should not be instantiated as it contains only static methods.
Public methods
databaseBuilder
@NonNull open static fun <T : RoomDatabase!> databaseBuilder(
@NonNull context: Context,
@NonNull klass: Class<T>,
@NonNull 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 | |
---|---|
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. |
<T> |
The type of the database class. |
Return | |
---|---|
RoomDatabase.Builder<T> |
A RoomDatabaseBuilder<T> which you can use to create the database. |
inMemoryDatabaseBuilder
@NonNull open static fun <T : RoomDatabase!> inMemoryDatabaseBuilder(
@NonNull context: Context,
@NonNull 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 | |
---|---|
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 . |
<T> |
The type of the database class. |
Return | |
---|---|
RoomDatabase.Builder<T> |
A RoomDatabaseBuilder<T> which you can use to create the database. |