Accessing the Database Using the Repository Pattern
To access your database, you will use the repository pattern recommended by Google in its Guide to App Architecture (developer.android.com/jetpack/docs/guide).
A repository class encapsulates the logic for accessing data from a single source or a set of sources. It determines how to fetch and store a particular set of data, whether locally in a database or from a remote server. Your UI code will request all the data from the repository, because the UI does not care how the data is actually stored or fetched. Those are implementation details of the repository itself.
Since CriminalIntent is a simpler app, the repository will only handle fetching data from the database. ...