Chapter 7

Working with the File System and Application Preferences

What's in This Chapter?

  • Reviewing the file system
  • Reading and writing a file
  • Creating and reading application shared preferences
  • Processing an XML file
  • Listening for preference changes

This chapter covers the file system, reading and writing files to the file system, and system and application preferences. The review of the file system covers the file system type and structure and gives examples of reading and writing text files from the application to the file system. For application preferences the chapter covers the API used for both shared and private preferences and preference change notification. The chapter also shows a program that uses the available preferences namespace to show a standard user preferences interface. Finally, the chapter shows how to process XML from an atom feed on the Internet.

User preferences are essential to providing a robust user experience, ensuring that users can tailor the software to their own liking. Also, in the context of Android, private preferences are important to maintaining user state in an environment where context changes can happen unexpectedly. For instance, if a user gets a call while keying data into your app, you want to be sure that when the user returns to the app, the input is still there. The samples in this chapter enable you to accomplish these tasks.

Working with the File System

As previously indicated, this chapter covers the file system and file I/O. ...

Get Professional Android Programming with Mono for Android and .NET/C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.