java.lang.Object | |
↳ | android.preference.PreferenceManager |
Used to help create Preference
hierarchies
from activities or XML.
In most cases, clients should use
addPreferencesFromIntent(Intent)
or
addPreferencesFromResource(int)
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
PreferenceManager.OnActivityDestroyListener | Interface definition for a class that will be called when the container's activity is destroyed. | ||||||||||
PreferenceManager.OnActivityResultListener | Interface definition for a class that will be called when the container's activity receives an activity result. | ||||||||||
PreferenceManager.OnActivityStopListener | Interface definition for a class that will be called when the container's activity is stopped. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | KEY_HAS_SET_DEFAULT_VALUES | ||||||||||
String | METADATA_KEY_PREFERENCES | The Activity meta-data key for its XML preference hierarchy. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Finds a
Preference based on its key.
| |||||||||||
Gets a SharedPreferences instance that points to the default file that is
used by the preference framework in the given context.
| |||||||||||
Gets a SharedPreferences instance that preferences managed by this will
use.
| |||||||||||
Returns the current mode of the SharedPreferences file that preferences managed by
this will use.
| |||||||||||
Returns the current name of the SharedPreferences file that preferences managed by
this will use.
| |||||||||||
Similar to
setDefaultValues(Context, int, boolean) but allows
the client to provide the filename and mode of the shared preferences
file.
| |||||||||||
Sets the default values from an XML preference file by reading the values defined
by each
Preference item's android:defaultValue attribute.
| |||||||||||
Sets the mode of the SharedPreferences file that preferences managed by this
will use.
| |||||||||||
Sets the name of the SharedPreferences file that preferences managed by this
will use.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
The Activity meta-data key for its XML preference hierarchy.
Finds a Preference
based on its key.
key | The key of the preference to retrieve. |
---|
Preference
with the key, or null.Gets a SharedPreferences instance that points to the default file that is used by the preference framework in the given context.
context | The context of the preferences whose values are wanted. |
---|
Gets a SharedPreferences instance that preferences managed by this will use.
Returns the current mode of the SharedPreferences file that preferences managed by this will use.
getSharedPreferences(String, int)
.Returns the current name of the SharedPreferences file that preferences managed by this will use.
getSharedPreferences(String, int)
.Similar to setDefaultValues(Context, int, boolean)
but allows
the client to provide the filename and mode of the shared preferences
file.
context | The context of the shared preferences. |
---|---|
sharedPreferencesName | A custom name for the shared preferences file. |
sharedPreferencesMode | The file creation mode for the shared preferences file, such
as MODE_PRIVATE or MODE_PRIVATE |
resId | The resource ID of the preference XML file. |
readAgain | Whether to re-read the default values.
If false, this method will set the default values only if this
method has never been called in the past (or if the
KEY_HAS_SET_DEFAULT_VALUES in the default value shared
preferences file is false). To attempt to set the default values again
bypassing this check, set readAgain to true.
Note: this will NOT reset preferences back to their default
values. For that functionality, use
|
Sets the default values from an XML preference file by reading the values defined
by each Preference
item's android:defaultValue
attribute. This should
be called by the application's main activity.
context | The context of the shared preferences. |
---|---|
resId | The resource ID of the preference XML file. |
readAgain | Whether to re-read the default values.
If false, this method sets the default values only if this
method has never been called in the past (or if the
KEY_HAS_SET_DEFAULT_VALUES in the default value shared
preferences file is false). To attempt to set the default values again
bypassing this check, set readAgain to true.
Note: this will NOT reset preferences back to their default
values. For that functionality, use
|
Sets the mode of the SharedPreferences file that preferences managed by this will use.
sharedPreferencesMode | The mode of the SharedPreferences file. |
---|
Sets the name of the SharedPreferences file that preferences managed by this will use.
sharedPreferencesName | The name of the SharedPreferences file. |
---|