Setup
Project's gradle
Module's gradle
Room
Room has three main components of Room DB :- Entity
- Dao
- Database
- Entity - Represents a table within the database. Room creates a table for each class that has @Entity annotation
- @PrimaryKey(autoGenerate = true)
- @ColumnInfo(name = “column_name”)
- @Ignore — field will not be persisted by Room
- @Embeded — nested fields can be referenced directly in the SQL queries.
- Dao - DAOs are responsible for defining the methods that access the database.
- Database - Contains the database holder and serves as the main access point for the underlying connection to your app’s persisted, relational data.
Example
(See on preview for gists visibility)
- SleepNight entity
- Dao
- Database
No hay comentarios:
Publicar un comentario