Working with Android’s Preference Framework Working with Android’s Preference Framework

327

Chapter 15: Working with Android’s Preference Framework

➝ 4 After changes are made to any of the preferences, you must call the commit method on the Editor object to persist them to SharedPreferences. The commit call automatically replaces any value that is currently stored in SharedPreferences with the key given in the putString call. If you do not call commit on the Editor object, your changes will not persist and your application will not function as you expect. By adding a preference screen to your application, you’ve given your appli- cation configurability, which will make the application more useful to end users. It’s fairly simple to add new preferences through code or through an XML preference declaration, so you have no excuse not to add them Making the app more configurable can give your power users the extra features that they are looking for. 328 Part III: Creating a Feature-Rich Application Part IV The Part of Tens In this part . . . P art IV consists of some of the best secret-sauce- covered Android nuggets that you acquire only after having been in the development trenches for quite some time. First, I list some of the best sample applications that can help springboard you on your way to creating the next hit application. These applications range from database- oriented apps to interactive games to applications that interact with third-party Web application programming interfaces APIs. I close Part IV with a list of professional tools and libraries that can help streamline and improve the productivity of your application development process and make your life as a developer much easier. Chapter 16 Ten Great Free Sample Applications and SDKs With Code In This Chapter ▶ Getting social ▶ Manipulating images ▶ Playing games ▶ Streaming music ▶ Checking out demos D uring your career as an Android developer, you may run into vari- ous roadblocks, many of which may be Android code based. Perhaps the functionality you’re after is communicating with a third-party API that returns JSON, or maybe you need to know how to perform collision detection in a game. When I run into such a circumstance, I usually end up searching the Web for sample code. Chances are that someone else has already written the code I’m after I can then review that code, alter it as needed, and continue with development. Sample code is great, but it’s just that — sample code. It’s not production ready. While I agree with this statement, I would like to add that reviewing sample code has an added side effect: It is a learning enhancer. A good way to find out how to program for Android is to look at the sample code Sure, sample code comes with the Android SDK — such as the API demos I mention in Chapter 2. But the real cool stuff is the plethora of real-world application code that is freely available on the Web You can find plenty of good-quality open-source applications that serve as great examples that are available on the Internet thanks to the open-source nature of Android.