lightbulb_outline Please take our October 2018 developer survey. Start survey
added in version 2.0.0
belongs to Maven artifact androidx.room:room-runtime:2.1.0-alpha01

DatabaseConfiguration

public class DatabaseConfiguration
extends Object

java.lang.Object
   ↳ androidx.room.DatabaseConfiguration


Configuration class for a RoomDatabase.

Summary

Fields

public final boolean allowDestructiveMigrationOnDowngrade

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

public final boolean allowMainThreadQueries

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

public final List<RoomDatabase.Callback> callbacks

public final Context context

The context to use while connecting to the database.

public final RoomDatabase.JournalMode journalMode

The journal mode for this database.

public final RoomDatabase.MigrationContainer migrationContainer

Collection of available migrations.

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.

public final String name

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

public final Executor queryExecutor

The Executor used to execute asynchronous queries.

public final boolean requireMigration

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

public final SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory

The factory to use to access the database.

Public methods

boolean isMigrationRequired(int fromVersion, int toVersion)

Returns whether a migration is required between two versions.

boolean isMigrationRequiredFrom(int version)

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

Inherited methods

Fields

allowDestructiveMigrationOnDowngrade

public final boolean allowDestructiveMigrationOnDowngrade

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

allowMainThreadQueries

added in version 2.0.0
public final boolean allowMainThreadQueries

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

callbacks

added in version 2.0.0
public final List<RoomDatabase.Callback> callbacks

context

added in version 2.0.0
public final Context context

The context to use while connecting to the database.

journalMode

added in version 2.0.0
public final RoomDatabase.JournalMode journalMode

The journal mode for this database.

migrationContainer

added in version 2.0.0
public final RoomDatabase.MigrationContainer migrationContainer

Collection of available migrations.

multiInstanceInvalidation

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 version 2.0.0
public final String name

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

queryExecutor

added in version 2.0.0
public final Executor queryExecutor

The Executor used to execute asynchronous queries.

requireMigration

added in version 2.0.0
public final boolean requireMigration

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

sqliteOpenHelperFactory

added in version 2.0.0
public final SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory

The factory to use to access the database.

Public methods

isMigrationRequired

public boolean isMigrationRequired (int fromVersion, 
                int toVersion)

Returns whether a migration is required between two versions.

Parameters
fromVersion int: The old schema version.

toVersion int: The new schema version.

Returns
boolean True if a valid migration is required, false otherwise.

isMigrationRequiredFrom

added in version 2.0.0
public boolean isMigrationRequiredFrom (int version)

This method is 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.

Returns
boolean True if a valid migration is required, false otherwise.