65.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:
public class CustomerRepository {
private CustomerDao customerDao;
private CustomerRoomDatabase db;
public CustomerRepository(Application application) {
db = 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 the getAllCustomers() DAO method:
private LiveData<List<Customer>...