Android Kotlin: Forecast App 03 – Local Database (Room Entity & Dao) – MVVM Tutorial Course
In the last episode we made a Retrofit service to fetch data from the weather API. We also used Gson to convert this data from JSON to Kotlin objects.
We could technically use only this Retrofit service and create a nice user interface to display all the data we are currently getting. Doing this wouldn’t be really performant and efficient though. What if the user doesn’t have an internet connection? Do we even really need to fetch data from the server every time the app is launched? Shouldn’t we cache all of this data?
The answer is YES! In this tutorial you are going to learn how to create a local SQLite database using the Room library. By the end of this tutorial, you will understand terms like entity or data access object (dao).