Working with Preferences and Saving State

  • Dave MacLean
  • Satya Komatineni
Chapter

Abstract

Android offers a robust and flexible framework for dealing with settings, also known as preferences. And by settings, we mean those feature choices that a user makes and saves to customize an application to their liking. (In this chapter, the terms settings and preferences will be used interchangeably.) For example, if the user wants a notification via a ringtone or vibration or not at all, that is a preference the user saves; the application remembers the choice until the user changes it. Android provides simple APIs that hide the management and persisting of preferences. It also provides prebuilt user interfaces that you can use to let the user make preference selections. Because of the power built into the Android preferences framework, we can also use preferences for more general-purpose storing of application state, to allow our application to pick up where it left off, should our application go away and come back later. As another example, a game's high scores could be stored as preferences, although you'll want to use your own UI to display them.

Keywords

Sample Application List Preference Shared Preference Summary Text Preference File 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Copyright information

© Dave MacLean 2014

Authors and Affiliations

  • Dave MacLean
    • 1
  • Satya Komatineni
    • 1
  1. 1.FLUnited States

Personalised recommendations