Skip to content

Most visited

Recently visited

navigation
added in version 1.0.0
belongs to Maven artifact android.arch.persistence.room:runtime:1.0.0

Room

public class Room
extends Object

java.lang.Object
   ↳ android.arch.persistence.room.Room


Utility class for Room.

Summary

Constants

String MASTER_TABLE_NAME

The master table where room keeps its metadata information.

Public constructors

Room()

Public methods

static <T extends RoomDatabase> Builder<T> databaseBuilder(Context context, Class<T> klass, String name)

Creates a RoomDatabase.Builder for a persistent database.

static <T extends RoomDatabase> Builder<T> inMemoryDatabaseBuilder(Context context, Class<T> klass)

Creates a RoomDatabase.Builder for an in memory database.

Inherited methods

From class java.lang.Object

Constants

MASTER_TABLE_NAME

added in version 1.0.0
String MASTER_TABLE_NAME

The master table where room keeps its metadata information.

Constant Value: "room_master_table"

Public constructors

Room

added in version 1.0.0
Room ()

Public methods

databaseBuilder

added in version 1.0.0
Builder<T> databaseBuilder (Context context, 
                Class<T> klass, 
                String name)

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: The abstract class which is annotated with Database and extends RoomDatabase.

name String: The name of the database file.

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

inMemoryDatabaseBuilder

added in version 1.0.0
Builder<T> inMemoryDatabaseBuilder (Context context, 
                Class<T> klass)

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: The abstract class which is annotated with Database and extends RoomDatabase.

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

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)