Room - Defining an Entity
This lesson will explain what a Room Entity is and demonstrate how to define it.
We'll walkthrough the creation of a Room Entity which will represent a
Task which can be tracked in our app. We'll see how to define the Task class as both a Room Entity as well as a Kotlin data class.
We'll add some fields to the
Task which can represent the title and the completion status, as well as an auto-incrementing ID which will be used to uniquely identify the
Task in the database.
Finally, we'll demonstrate how to register the entity with Room.
Summary of content
- What a Room entity is
- How to define a simple entity
- Using a Kotlin data class as a Room entity
- Autogenerate primary key
- Requirement to use
valfor entity fields
- Registering entities with the Room database