73.6 The Repository
The repository is responsible for getting a Room Database instance, using that instance to access associated DAOs and then making calls to DAO methods to perform database operations. A typical constructor for a repository designed to work with a Room Database might read as follows:
class CustomerRepository(application: Application) {
private var customerDao: CustomerDao?
init {
val db: CustomerRoomDatabase? =
CustomerRoomDatabase.getDatabase(application)
customerDao = db?.customerDao()
}
.
.
Once the repository has access to the DAO, it can make calls to the data access methods. The following code, for example, calls...