Recall & Review
beginner
What is an <strong>Entity</strong> class in Android Room?An Entity class represents a table in the database. Each instance of the class is a row in that table. It uses annotations like @Entity and @PrimaryKey to define the table and its primary key.Click to reveal answer
beginner
What does a DAO (Data Access Object) do in Room?
A DAO defines methods to access the database, like inserting, updating, deleting, and querying data. It uses annotations like @Insert, @Update, @Delete, and @Query to specify SQL operations.
Click to reveal answer
beginner
What is the role of the <strong>Database</strong> class in Room?The Database class holds the database and serves as the main access point. It is an abstract class annotated with @Database and lists the entities and version. It provides abstract methods to get DAOs.Click to reveal answer
intermediate
Why do we use annotations like @Entity, @Dao, and @Database in Room?
Annotations tell Room how to generate the necessary code. @Entity marks a data class as a table, @Dao marks an interface or abstract class for database operations, and @Database defines the database configuration.Click to reveal answer
intermediate
How does Room help with database operations compared to raw SQLite?
Room provides a simple, type-safe way to work with SQLite databases. It reduces boilerplate code, handles SQL queries with annotations, and integrates with Kotlin coroutines and LiveData for reactive apps.
Click to reveal answer
Which annotation marks a Kotlin data class as a database table in Room?
✗ Incorrect
The @Entity annotation marks a class as a table in Room.
What does the @Dao annotation indicate?
✗ Incorrect
The @Dao annotation marks an interface or abstract class that contains methods to access the database.
Which class holds the database and provides DAOs in Room?
✗ Incorrect
The Database class is the main access point to the database and provides DAOs.
Which annotation specifies the database version in Room?
✗ Incorrect
The @Database annotation includes the version number of the database.
What is the purpose of the @PrimaryKey annotation in an Entity?
✗ Incorrect
The @PrimaryKey annotation marks a field as the unique identifier for each row in the table.
Explain the roles of Entity, DAO, and Database classes in Android Room.
Think about how data is stored, accessed, and managed.
You got /3 concepts.
Describe how annotations help Room generate database code.
Annotations are like labels telling Room what to do.
You got /4 concepts.