DatabaseConfiguration

public class DatabaseConfiguration


Configuration class for a RoomDatabase.

Summary

Public fields

final boolean
final boolean

Whether Room should throw an exception for queries run on the main thread.

final @NonNull List<@NonNull AutoMigrationSpec>
final List<@NonNull RoomDatabase.Callback>
final @NonNull Context

The context to use while connecting to the database.

final String
final File
final Callable<@NonNull InputStream>
final @NonNull RoomDatabase.JournalMode

The journal mode for this database.

final @NonNull RoomDatabase.MigrationContainer

Collection of available migrations.

final boolean

If true, table invalidation in an instance of RoomDatabase is broadcast and synchronized with other instances of the same RoomDatabase file, including those in a separate process.

final String

The name of the database file or null if it is an in-memory database.

final RoomDatabase.PrepackagedDatabaseCallback
final @NonNull Executor

The Executor used to execute asynchronous queries.

final boolean
final @NonNull SupportSQLiteOpenHelper.Factory

The factory to use to access the database.

final @NonNull Executor

The Executor used to execute asynchronous transactions.

final @NonNull List<@NonNull Object>

Public methods

boolean
isMigrationRequired(int fromVersion, int toVersion)

Returns whether a migration is required between two versions.

boolean

This method is deprecated. Use [isMigrationRequired(int, int)] which takes [allowDestructiveMigrationOnDowngrade] into account.

Public fields

allowDestructiveMigrationOnDowngrade

Added in 2.1.0
public final boolean allowDestructiveMigrationOnDowngrade

allowMainThreadQueries

Added in 2.0.0
public final boolean allowMainThreadQueries

Whether Room should throw an exception for queries run on the main thread.

autoMigrationSpecs

Added in 2.4.0
public final @NonNull List<@NonNull AutoMigrationSpecautoMigrationSpecs

callbacks

Added in 2.0.0
public final List<@NonNull RoomDatabase.Callbackcallbacks

context

Added in 2.0.0
public final @NonNull Context context

The context to use while connecting to the database.

copyFromAssetPath

Added in 2.2.0
public final String copyFromAssetPath

copyFromFile

Added in 2.2.0
public final File copyFromFile

copyFromInputStream

Added in 2.3.0
public final Callable<@NonNull InputStreamcopyFromInputStream

journalMode

Added in 2.0.0
public final @NonNull RoomDatabase.JournalMode journalMode

The journal mode for this database.

migrationContainer

Added in 2.0.0
public final @NonNull RoomDatabase.MigrationContainer migrationContainer

Collection of available migrations.

multiInstanceInvalidation

Added in 2.1.0
public final boolean multiInstanceInvalidation

If true, table invalidation in an instance of RoomDatabase is broadcast and synchronized with other instances of the same RoomDatabase file, including those in a separate process.

name

Added in 2.0.0
public final String name

The name of the database file or null if it is an in-memory database.

prepackagedDatabaseCallback

Added in 2.3.0
public final RoomDatabase.PrepackagedDatabaseCallback prepackagedDatabaseCallback

queryExecutor

Added in 2.0.0
public final @NonNull Executor queryExecutor

The Executor used to execute asynchronous queries.

requireMigration

Added in 2.0.0
public final boolean requireMigration

sqliteOpenHelperFactory

Added in 2.0.0
public final @NonNull SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory

The factory to use to access the database.

transactionExecutor

Added in 2.1.0
public final @NonNull Executor transactionExecutor

The Executor used to execute asynchronous transactions.

typeConverters

Added in 2.3.0
public final @NonNull List<@NonNull ObjecttypeConverters

Public methods

isMigrationRequired

Added in 2.1.0
public boolean isMigrationRequired(int fromVersion, int toVersion)

Returns whether a migration is required between two versions.

Parameters
int fromVersion

The old schema version.

int toVersion

The new schema version.

Returns
boolean

True if a valid migration is required, false otherwise.

isMigrationRequiredFrom

Added in 2.0.0
Deprecated in 2.1.0
public boolean isMigrationRequiredFrom(int version)

Returns whether a migration is required from the specified version.

Parameters
int version

The schema version.

Returns
boolean

True if a valid migration is required, false otherwise.