In This Chapter
I consider myself a power user of computer software, and I'm sure that you're a power user as well. I know that most programs can be configured to suit my needs (for the most part), and I usually go out of my way to find the settings or preferences to set up my favorite configuration for a given program. Allowing your users to do the same in your Android application gives your application an advantage in regard to usability. Thankfully, creating and providing a mechanism to edit preferences in Android are fairly easy processes.
Out of the box, Android provides a robust preference framework that allows you to declaratively as well as programmatically define preferences for your application. Android stores preferences as persistent key-value pairs of primitive data types for you. You are not required to store the values in a file, database, or any other mechanism. The Android preference framework takes the values you provide and commits them to internal storage on behalf of your application. You can use the preference framework to store booleans, floats, ints, longs, and strings. The data persists across user sessions as well — meaning that if the user closes the app and reopens it later, the preferences are saved and can be used again. This is true even if your application is killed.
In this chapter, ...