11
Databases and the Room Library

Almost every application needs a place to save data for the long term. In this chapter you will implement a database for CriminalIntent and seed it with dummy data. Then you will update the app to pull crime data from the database and display it in the crime list (Figure 11.1).

Figure 11.1  Displaying crimes from the database

Displaying crimes from the database

In Chapter 4 you learned how to persist transient UI state data across rotation and process death using ViewModel and saved instance state. These two approaches are great for small amounts of data tied to the UI. However, these approaches should not be used for storing non-UI data or data that is not tied to an activity or fragment instance and needs to persist regardless of UI state.

Instead, store your non-UI app data either locally (on the filesystem or in a database, as you will do for CriminalIntent) or on a web server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
44.223.36.100