androidx.room3


Interfaces

PooledConnection

A wrapper of SQLiteConnection that belongs to a connection pool and is safe to use in a coroutine.

Cmn
RoomDatabaseConstructor

Defines a class that can instantiate the Room generated implementation of an 'abstract' Database annotated RoomDatabase definition.

Cmn
RoomOpenDelegateMarker

Marker interface for Room's code generated delegate.

Cmn
TransactionScope

A PooledConnection with an active transaction capable of performing nested transactions.

Cmn
Transactor

A PooledConnection that can perform transactions.

Cmn

Classes

DatabaseConfiguration

Configuration class for a RoomDatabase.

Cmn
android
N
InvalidationTracker

The invalidation tracker keeps track of tables modified by queries and notifies its created Flows about such modifications.

Cmn
android
N
MultiInstanceInvalidationService

A Service for remote invalidation among multiple InvalidationTracker instances.

android
RoomDatabase

Base class for all Room databases.

Cmn
android
N
RoomDatabase.Builder

Builder for RoomDatabase.

Cmn
android
N
RoomDatabase.Callback

Callback for RoomDatabase

Cmn
android
N
RoomDatabase.MigrationContainer

A container to hold migrations.

Cmn
android
N
RoomDatabase.PrepackagedDatabaseCallback

Callback for Builder.createFromAsset, Builder.createFromFile and Builder.createFromInputStream

android
RoomRawQuery

A query with an argument binding function.

Cmn

Objects

FtsOptions

Available option values that can be used with Fts3&Fts4.

Cmn
Room

Entry point for building and initializing a RoomDatabase.

Cmn
android
N
JS
RoomWarnings

The list of warnings that are produced by Room.

Cmn

Annotations

AutoMigration

Declares an automatic migration on a Database.

Cmn
BuiltInTypeConverters

Flags to turn on / off extra type converters provided by Room.

Cmn
ColumnInfo

Allows specific customization about the column associated with the annotated property.

Cmn
ColumnInfo.Collate
Cmn
ColumnInfo.SQLiteTypeAffinity

The SQLite column type constants that can be used in ColumnInfo.typeAffinity

Cmn
ConstructedBy

Defines the androidx.room3.RoomDatabaseConstructor that will instantiate the Room generated implementation of the annotated Database.

Cmn
android
N
JS
Dao

Marks the class as a Data Access Object.

Cmn
DaoReturnTypeConverter

Marks a function as a DAO function return type converter.

Cmn
DaoReturnTypeConverters

Specifies the classes that contain DAO return type converters that a RoomDatabase can use.

Cmn
Database

Marks a class as a androidx.room3.RoomDatabase.

Cmn
DatabaseView

Marks a class as an SQLite view.

Cmn
Delete

Marks a function in a Dao annotated class as a delete function.

Cmn
DeleteColumn

Repeatable annotation declaring the deleted columns in the AutoMigration.to version of an auto migration.

Cmn
android
DeleteColumn.Entries

Container annotation for the repeatable annotation DeleteColumn.

android
DeleteTable

Repeatable annotation declaring the deleted tables in the AutoMigration.to version of an auto migration.

Cmn
android
DeleteTable.Entries

Container annotation for the repeatable annotation DeleteTable.

android
Embedded

Marks a property of an Entity or data object to allow nested properties (i.e. properties of the annotated property's class) to be referenced directly in the SQL queries.

Cmn
Entity

Marks a class as an entity.

Cmn
ExperimentalRoomApi

Marks declarations that are experimental in Room's APIs, which means that the design of the corresponding declarations may (or may not) lead to their changes in the future.

Cmn
ForeignKey

Declares a foreign key on another Entity.

Cmn
ForeignKey.Action

Constants definition for values that can be used in onDelete and onUpdate.

Cmn
Fts3

Marks an Entity annotated class as a FTS3 entity.

Cmn
Fts4

Marks an Entity annotated class as a FTS4 entity.

Cmn
Ignore

Ignores the marked element from Room's processing logic.

Cmn
Index

Declares an index on an Entity.

Cmn
Insert

Marks a function in a Dao annotated class as an insert function.

Cmn
Junction

Declares a junction to be used for joining a relationship.

Cmn
MapColumn

Declares which column is used to build a map or multimap return value in a Dao query function.

Cmn
OnConflictStrategy

Set of conflict handling strategies for various Dao functions.

Cmn
PrimaryKey

Marks a property in an Entity as the primary key.

Cmn
ProvidedAutoMigrationSpec

Marks a androidx.room3.migration.AutoMigrationSpec class that will be provided to Room at runtime.

Cmn
ProvidedTypeConverter

Marks a class containing TypeConverter functions that will be provided to Room at runtime.

Cmn
Query

Marks a function in a Dao annotated class as a query function.

Cmn
RawQuery

Marks a function in a Dao annotated class as a raw query function where the query is pass as a parameter of types androidx.room3.RoomRawQuery or androidx.sqlite.db.SupportSQLiteQuery.

Cmn
Relation

A convenience annotation which can be used in a data object class to automatically fetch relation entities.

Cmn
RenameColumn

Repeatable annotation declaring the renamed columns in the AutoMigration.to version of an auto migration.

Cmn
android
RenameColumn.Entries

Container annotation for the repeatable annotation RenameColumn.

android
RenameTable

Repeatable annotation declaring the renamed tables in the new version of an auto migration.

Cmn
android
RenameTable.Entries

Container annotation for the repeatable annotation RenameTable.

android
RewriteQueriesToDropUnusedColumns

When present, RewriteQueriesToDropUnusedColumns annotation will cause Room to rewrite your Query functions such that only the columns that are used in the return type are queried from the database.

Cmn
SkipQueryVerification

Skips database verification for the annotated element.

Cmn
Transaction

Marks a function in a Dao class as a transaction function.

Cmn
TypeConverter

Marks a function as a type converter.

Cmn
TypeConverters

Specifies additional type converters that Room can use.

Cmn
Update

Marks a function in a Dao annotated class as an update function.

Cmn
Upsert

Marks a function in a Dao annotated class as an upsert (insert or update) function.

Cmn

Enums

BuiltInTypeConverters.State

Control flags for built-in converters.

Cmn
FtsOptions.MatchInfo
Cmn
FtsOptions.Order
Cmn
Index.Order
Cmn
OperationType

Describes the type of database operation a DaoReturnTypeConverter function supports.

Cmn
RoomDatabase.JournalMode

Journal modes for SQLite database.

Cmn
android
N
Transactor.SQLiteTransactionType

Transaction types.

Cmn

Extension functions summary

suspend R
<R : Any?> Transactor.deferredTransaction(block: suspend TransactionScope<R>.() -> R)

Performs a SQLiteTransactionType.DEFERRED within the block.

Cmn
suspend R
<R : Any?> Transactor.exclusiveTransaction(block: suspend TransactionScope<R>.() -> R)

Performs a SQLiteTransactionType.EXCLUSIVE within the block.

Cmn
suspend Unit

Executes a single SQL statement that returns no values.

Cmn
suspend R
<R : Any?> Transactor.immediateTransaction(block: suspend TransactionScope<R>.() -> R)

Performs a SQLiteTransactionType.IMMEDIATE within the block.

Cmn
suspend R
<R : Any?> RoomDatabase.useReaderConnection(block: suspend (Transactor) -> R)

Acquires a READ connection, suspending while waiting if none is available and then calling the block to use the connection once it is acquired.

Cmn
suspend R
<R : Any?> RoomDatabase.useWriterConnection(block: suspend (Transactor) -> R)

Acquires a WRITE connection, suspending while waiting if none is available and then calling the block to use the connection once it is acquired.

Cmn
suspend R
<R : Any?> RoomDatabase.withReadTransaction(block: suspend TransactionScope<R>.() -> R)

Acquire a READ connection and start a Transactor.SQLiteTransactionType.DEFERRED transaction to execute the given block within the transaction.

Cmn
suspend R
<R : Any?> RoomDatabase.withWriteTransaction(block: suspend TransactionScope<R>.() -> R)

Acquire a WRITE connection and start a Transactor.SQLiteTransactionType.IMMEDIATE transaction to execute the given block within the transaction.

Cmn

Extension functions

deferredTransaction

suspend fun <R : Any?> Transactor.deferredTransaction(block: suspend TransactionScope<R>.() -> R): R

Performs a SQLiteTransactionType.DEFERRED within the block.

exclusiveTransaction

suspend fun <R : Any?> Transactor.exclusiveTransaction(block: suspend TransactionScope<R>.() -> R): R

Performs a SQLiteTransactionType.EXCLUSIVE within the block.

executeSQL

suspend fun PooledConnection.executeSQL(sql: String): Unit

Executes a single SQL statement that returns no values.

immediateTransaction

suspend fun <R : Any?> Transactor.immediateTransaction(block: suspend TransactionScope<R>.() -> R): R

Performs a SQLiteTransactionType.IMMEDIATE within the block.

useReaderConnection

suspend fun <R : Any?> RoomDatabase.useReaderConnection(block: suspend (Transactor) -> R): R

Acquires a READ connection, suspending while waiting if none is available and then calling the block to use the connection once it is acquired. A RoomDatabase will have one or more READ connections. The connection to use in the block is an instance of Transactor that provides the capabilities for performing nested transactions.

Using the connection after block completes is prohibited.

The connection will be confined to the coroutine on which block executes, attempting to use the connection from a different coroutine will result in an error.

If the current coroutine calling this function already has a confined connection, then that connection is used.

A connection is a limited resource and should not be held for more than it is needed. The best practice in using connections is to avoid executing long-running computations within the block. If a caller has to wait too long to acquire a connection a SQLiteException will be thrown due to a timeout.

Parameters
block: suspend (Transactor) -> R

The code to use the connection.

Throws
SQLiteException

when the database is closed or a thread confined connection needs to be upgraded or there is a timeout acquiring a connection.

useWriterConnection

suspend fun <R : Any?> RoomDatabase.useWriterConnection(block: suspend (Transactor) -> R): R

Acquires a WRITE connection, suspending while waiting if none is available and then calling the block to use the connection once it is acquired. A RoomDatabase will have only one WRITE connection. The connection to use in the block is an instance of Transactor that provides the capabilities for performing nested transactions.

Using the connection after block completes is prohibited.

The connection will be confined to the coroutine on which block executes, attempting to use the connection from a different coroutine will result in an error.

If the current coroutine calling this function already has a confined connection, then that connection is used as long as it isn't required to be upgraded to a writer. If an upgrade is required then a SQLiteException is thrown.

A connection is a limited resource and should not be held for more than it is needed. The best practice in using connections is to avoid executing long-running computations within the block. If a caller has to wait too long to acquire a connection a SQLiteException will be thrown due to a timeout.

Parameters
block: suspend (Transactor) -> R

The code to use the connection.

Throws
SQLiteException

when the database is closed or a thread confined connection needs to be upgraded or there is a timeout acquiring a connection.

withReadTransaction

suspend fun <R : Any?> RoomDatabase.withReadTransaction(block: suspend TransactionScope<R>.() -> R): R

Acquire a READ connection and start a Transactor.SQLiteTransactionType.DEFERRED transaction to execute the given block within the transaction.

This function is a shorthand of:

roomDatabase.useReaderConnection { it.withTransaction(DEFERRED) { block() } }

withWriteTransaction

suspend fun <R : Any?> RoomDatabase.withWriteTransaction(block: suspend TransactionScope<R>.() -> R): R

Acquire a WRITE connection and start a Transactor.SQLiteTransactionType.IMMEDIATE transaction to execute the given block within the transaction.

This function is a shorthand of:

roomDatabase.useWriterConnection { it.withTransaction(IMMEDIATE) { block() } }