O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

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

Preferences

Preferences are implemented through use of the SharedPreferences class. A SharedPreferences object can be used to store primitive data (for example, integers and strings) in a key/value pair. Each value has its own key for storage and retrieval of that data. SharedPreferences are stored in memory private to the app and will persist as long as the app remains installed on the device. App upgrades will not impact the values stored with SharedPreferences.

There are two main modes for accessing SharedPreferences: getSharedPreferences("String preference name", integer mode) and getPreferences(integer mode). The getSharedPreferences mode is used when you want to have more than one set of preferences for an app, or you want the 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