Room Database
DATA › Storage
Tests Room's entities, DAOs, queries, migrations, type converters, relations, and observable Flow queries.
Room is the standard persistence layer for Android, an abstraction over SQLite that interviewers use to probe whether you understand compile-time SQL validation, schema versioning, and reactive data flows. Expect to define entities, DAOs, and the database class, then explain what breaks during a version bump and how observable queries integrate with coroutines. Strong answers connect the annotations to the generated code and to threading/lifecycle concerns.
What this covers
- Declaring @Entity tables, @Dao interfaces, and the @Database class, plus building a singleton via Room.databaseBuilder
- @Insert/@Update/@Delete (primary-key matching, return values, OnConflictStrategy) versus @Query with compile-time SQL validation
- Writing Migration(from, to) objects, addMigrations, and what happens when no migration path exists
- Type converters for unsupported types (Date, enums, lists) and @Relation for one-to-many / many-to-many
- Returning Flow/LiveData for observable queries versus suspend functions for one-shot reads and writes
- How KSP annotation processing generates the DAO and database implementations at build time
Study this topic
- Room Database explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Room Database interview questions and answers