Книга: Beginning Android
Stating Your Preference
Stating Your Preference
Given the appropriate SharedPreferences
object, you can use edit() to get an “editor” for the preferences. This object has a group of setters that mirror the getters on the parent SharedPreferences
object. It also has the following:
• remove()
to get rid of a single named preference
• clear()
to get rid of all preferences
• commit()
to persist your changes made via the editor
The last one is important — if you modify preferences via the editor and fail to commit()
the changes, those changes will evaporate once the editor goes out of scope.
Conversely, since the preferences object supports live changes, if one part of your application (say, an activity) modifies shared preferences, another part of your application (say, a service) will have access to the changed value immediately.
- CHAPTER 17 Using Preferences
- Chapter 12. Debugging your scripts
- Listing your active rule-set
- Updating and flushing your tables
- How to use this License for your documents
- 2. How to Apply These Terms to Your New Programs
- Scaling makes your object darker?
- Partitioning Your Hard Drive
- Keeping Your Software Up-to-Date
- Assessing Your Backup Needs and Resources
- Building the Source Yourself
- Your Own Domain Name and Third-Party DNS