
Kickstart Modern Android Development with Jetpack and Kotlin
By :

We want to locally cache all the restaurants that we receive from our Firebase database. Since this content is structured, we want to use Room to help us with this task.
Essentially, we are trying to save the restaurants when the user is browsing our Restaurants app while online. Then, we will reuse them when the user browses the app while being offline:
Figure 6.2 – Data retrieval for the Restaurants app with two sources of truth
When online, we retrieve the restaurants from our web API. Before displaying them to the user, first, we will cache them to our Room database. If offline, we will retrieve the restaurants from the Room database and then display them to the user.
Essentially, we are creating two sources of truth for our app:
In the next section, we will discuss why this approach...