O'Reilly logo

Beginning Android 2 by Mark L. Murphy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 21

Using Preferences

Android has many different ways for you to store data for long-term use by your activity. The simplest to use is the preferences system, which is the topic of this chapter.

Android allows activities and applications to keep preferences, in the form of key/value pairs (akin to a Map), which will hang around between invocations of an activity. As the name suggests, the primary purpose is for you to store user-specified configuration details, such as the last feed the user looked at in your feed reader, the sort order to use by default on a list, or whatever. Of course, you can store in the preferences whatever you like, as long as it is keyed by a String and has a primitive value (boolean, String, etc.)

Preferences ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required