Chapter 7Data Persistence

This chapter describes how to persist data in your Android applications. Persisting data is an important topic in application development because users typically expect to reuse data in the future. For Android, there are primarily three basic ways of persisting data:

  • A lightweight mechanism known as shared preferences to save small chunks of data
  • Traditional file systems
  • A relational database management system through the support of SQLite databases

The techniques discussed in this chapter enable applications to create and access their own ­private data. Chapter 8 shows you how to share data across applications.

SAVING AND LOADING USER PREFERENCES

Android provides the SharedPreferences object to help you save simple application data. For example, your application may have an option that enables users to specify the font size used in your application. In this case, your application needs to remember the size set by the user so that ...

Get Beginning Android Programming with Android Studio, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.