O'Reilly logo

Android App Development For Dummies, 3rd Edition by Michael Burton

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 15

Working with Android Preferences

In This Chapter

arrow Seeing how preferences work in Android

arrow Building a preferences screen

arrow Working with preferences programmatically

Most programs need to be configured to suit a user’s needs with ­individual settings or preferences. Allowing users to configure your Android application gives it a usability advantage. Thankfully, creating and providing a mechanism to edit preferences in Android is a fairly easy ­process.

Android provides, out of the box, a robust preferences framework that lets you define preferences for your application. Android stores preferences as persistent key‐value pairs of primitive data types for you. The Android preferences framework commits the values you provide to internal storage on behalf of your application. You can use the preferences framework to store Boolean, float, int, long, and string elements. The data persists across user sessions — if the user closes the app and reopens it later, the preferences are saved and can be used, even if your application is killed or the phone restarts.

This chapter delves into the Android preferences framework and describes how to incorporate it into your applications. You ...

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