Google 致力于为黑人社区推动种族平等。查看具体举措

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 String copyFromAssetPath

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

public final File copyFromFile

The pre-packaged database file to copy from.

public final Callable<InputStream> copyFromInputStream

The callable to get the input stream from which a pre-package database file will be copied from.

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 RoomDatabase.PrepackagedDatabaseCallback prepackagedDatabaseCallback

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 final Executor transactionExecutor

The Executor used to execute asynchronous transactions.

public final List<Object> typeConverters

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

public final boolean allowMainThreadQueries

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

callbacks

public final List<RoomDatabase.Callback> callbacks

context

public final Context context

The context to use while connecting to the database.

copyFromAssetPath

public final String copyFromAssetPath

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

copyFromFile

public final File copyFromFile

The pre-packaged database file to copy from.

copyFromInputStream

public final Callable<InputStream> copyFromInputStream

The callable to get the input stream from which a pre-package database file will be copied from.

journalMode

public final RoomDatabase.JournalMode journalMode

The journal mode for this database.

migrationContainer

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

public final String name

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

prepackagedDatabaseCallback

public final RoomDatabase.PrepackagedDatabaseCallback prepackagedDatabaseCallback

queryExecutor

public final Executor queryExecutor

The Executor used to execute asynchronous queries.

requireMigration

public final boolean requireMigration

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

sqliteOpenHelperFactory

public final SupportSQLiteOpenHelper.Factory sqliteOpenHelperFactory

The factory to use to access the database.

transactionExecutor

public final Executor transactionExecutor

The Executor used to execute asynchronous transactions.

typeConverters

public final List<Object> typeConverters

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

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.