To accomplish many of the activities offered by modern mobile phones, such as tracking contacts, events, and tasks, a mobile operating system and its applications must be adept at storing and keeping track of large quantities of data. This data is usually structured in rows and columns, similar to a spreadsheet or a very simple database. Beyond a traditional application’s requirements for storing data, the Android application life cycle demands rapid and consistent persistence of data for it to survive the volatility of the mobile environment, where devices can suddenly lose power or the Android operating system can arbitrarily decide to remove your application from memory.
Android provides the lightweight but powerful SQLite relational database engine for persisting data. Furthermore, as described in Chapter 3, the content provider feature lets applications expose their data to other applications.
In this chapter, we provide a simple SQL tutorial so that you can learn to work with Android SQLite persistence. We also walk you through an interesting application—MJAndroid—that provides a real-world look at how to manipulate a database in Android. Later, in Chapter 15, we’ll reference the same example to demonstrate the use of the mapping API in Android. Chapter 12 will show you how to implement a content provider.
A relational database provides an efficient, structured, and generic system for managing persistent information. ...