Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android
by Jakob Iversen, Michael Eierman
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access