Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

DatabaseConfiguration

open class DatabaseConfiguration
kotlin.Any
   ↳ androidx.room.DatabaseConfiguration

Configuration class for a RoomDatabase.

Summary

Public methods

open Boolean
isMigrationRequired(fromVersion: Int, toVersion: Int)

Returns whether a migration is required between two versions.

open Boolean

Returns whether a migration is required from the specified version.

Properties

Boolean

If true, Room should perform a destructive migration when downgrading without an available migration.

Boolean

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

MutableList<RoomDatabase.Callback!>?

Context

The context to use while connecting to the database.

String?

The assets path to a pre-packaged database to copy from.

File?

The pre-packaged database file to copy from.

RoomDatabase.JournalMode!

The journal mode for this database.

RoomDatabase.MigrationContainer

Collection of available migrations.

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.

String?

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

Executor

The Executor used to execute asynchronous queries.

Boolean

If true, Room should crash if a migration is missing.

SupportSQLiteOpenHelper.Factory

The factory to use to access the database.

Executor

The Executor used to execute asynchronous transactions.

Public methods

isMigrationRequired

open fun isMigrationRequired(fromVersion: Int, toVersion: Int): Boolean

Returns whether a migration is required between two versions.

Parameters
fromVersion Int: The old schema version.
toVersion Int: The new schema version.
Return
Boolean: True if a valid migration is required, false otherwise.

isMigrationRequiredFrom

open fun isMigrationRequiredFrom(version: Int): Boolean

Deprecated: Use isMigrationRequired(int, int) which takes allowDestructiveMigrationOnDowngrade into account.

Returns whether a migration is required from the specified version.

Parameters
version Int: The schema version.
Return
Boolean: True if a valid migration is required, false otherwise.

Properties

allowDestructiveMigrationOnDowngrade

val allowDestructiveMigrationOnDowngrade: Boolean

If true, Room should perform a destructive migration when downgrading without an available migration.

allowMainThreadQueries

val allowMainThreadQueries: Boolean

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

callbacks

@Nullable val callbacks: MutableList<RoomDatabase.Callback!>?

context

@NonNull val context: Context

The context to use while connecting to the database.

copyFromAssetPath

@Nullable val copyFromAssetPath: String?

The assets path to a pre-packaged database to copy from.

copyFromFile

@Nullable val copyFromFile: File?

The pre-packaged database file to copy from.

journalMode

val journalMode: RoomDatabase.JournalMode!

The journal mode for this database.

migrationContainer

@NonNull val migrationContainer: RoomDatabase.MigrationContainer

Collection of available migrations.

multiInstanceInvalidation

val multiInstanceInvalidation: 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.

name

@Nullable val name: String?

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

queryExecutor

@NonNull val queryExecutor: Executor

The Executor used to execute asynchronous queries.

requireMigration

val requireMigration: Boolean

If true, Room should crash if a migration is missing.

sqliteOpenHelperFactory

@NonNull val sqliteOpenHelperFactory: SupportSQLiteOpenHelper.Factory

The factory to use to access the database.

transactionExecutor

@NonNull val transactionExecutor: Executor

The Executor used to execute asynchronous transactions.