1/15
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is Room in Android development?
disigned to simplify database access and interaction in Android apps
What are the three main components of Room?
Entities
DAO
Database
What is an entity in Room?
a class that represents a table in the database,
How do you define a primary key in Room?
Use the @PrimaryKey
annotation. To auto-generate it, set autoGenerate = true
.
What does @ColumnInfo
do?
Specifies custom column names when the field name differs from the database column name.
What is the purpose of a DAO in Room?
provides methods to interact with the database
What annotations are used in DAOs?
@Insert
– Adds new data.
@Update
– Modifies existing data.
@Delete
– Removes data.
@Query
– Executes custom SQL queries.
What is the role of a RoomDatabase class?
It serves as the main access point to the database and provides DAOs.
What is a migration in Room?
is used to update the database schema when the database version changes.
How does Room support reactive programming?
By providing support for LiveData
and Flow
, which automatically update the UI when data changes.
How does Room support coroutines?
Room allows database operations to be marked as suspend
functions, ensuring they run asynchronously.
Why should database operations not be performed on the main thread?
To prevent UI lag and ensure smooth app performance.
How does Room enforce background execution?
By supporting coroutines, LiveData, and Flow to handle database operations off the main thread.
What is a database transaction in Room?
groups multiple database operations to ensure that either all changes are applied or none at all if an operation fails.
How does Room integrate with Jetpack Compose?
It provides reactive data via LiveData
and Flow
,
What are the key benefits of using Room?
Ease of Use
Jetpack Integration
Thread Safety
Reactive Data