Room Database
Persist structured data locally with Room. Define Entities, DAOs, and the Database class. Query with SQL and observe results with LiveData or Flow.
What Is Room?
Room is Google's recommended persistence library for Android. It's a wrapper around SQLite that gives you:
- Type-safe SQL queries verified at compile time
- Kotlin coroutine support
- LiveData / Flow integration
- Migration support for schema changes
Room's Three Components
Room is built from three annotations:
@Entity— a data class that maps to a database table@Dao(Data Access Object) — an interface with SQL queries@Database— the main database class that ties everything together