Room - Creating a Data Access Object (DAO)
In order to interact with the database, Room makes use of the Data Access Object pattern, otherwise known as a DAO. This lesson describes what a DAO is and how it can be defined in Room.
A DAO is an object which serves as a gateway between the database and the rest of the app. As such, all interactions that require reading from or writing to the database will go through a DAO object.
This lesson will walk you through defining a DAO for our Task entity, including use of the @Dao annotation and how the DAO should be registered with Room so that instances of the DAO can be created by the database.
Summary of content
- What a Data Access Object (DAO) is
- Defining a DAO for Tasks as an interface
- @Dao annotation
- How to register a DAO with the Room database
- How to obtain an instance of your DAO from the database