Creating the database
To understand how databases work in Android, we will continue working on our example app, MasteringAndroidApp
, creating a database to store the job offers that will be used to see the content in offline mode. This means that if we open the app once, the job offers will be kept in the device allowing us to see the information if opened without an Internet connection.
There are four mechanisms to persist data in Android:
Shared preferences: These preferences are used to store basic information in a key-value structure
The internal storage: This storage saves files that are private to your app
The external storage: This storage saves files which can be shared with other apps
The SQLite database: This database, based on the popular SQL, allows us to write and read information in a structured way
We can create simple structures, such as one-table databases, as well as complex structures with more than one table. We can combine the output of different tables to create complex...