The Room Database Class
Create and access your database.
Tying It Together
The database class is the main access point. It lists your entities, declares the version, and exposes your DAOs.
The @Database Annotation
Create an abstract class extending RoomDatabase and annotate it with @Database.
import androidx.room.Database
import androidx.room.RoomDatabase
@Database(
entities = [User::class],
version = 1
)
abstract class AppDatabase : RoomDatabase() {
abstract fun userDao(): UserDao
}All lessons in this course
- Entities and DAOs
- The Room Database Class
- Queries and Relationships
- Observing Data with Flow