java.lang.Object | |
↳ | android.support.v7.preference.PreferenceManager |
Used to help create Preference
hierarchies
from activities or XML.
In most cases, clients should use
addPreferencesFromResource(int)
, or
addPreferencesFromResource(int)
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
PreferenceManager.OnDisplayPreferenceDialogListener |
Interface definition for a class that will be called when a
Preference requests to display a dialog.
|
||||||||||
PreferenceManager.OnNavigateToScreenListener |
Interface definition for a class that will be called when a
PreferenceScreen requests navigation.
|
||||||||||
PreferenceManager.OnPreferenceTreeClickListener |
Interface definition for a callback to be invoked when a
Preference in the hierarchy rooted at this PreferenceScreen is
clicked.
|
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | KEY_HAS_SET_DEFAULT_VALUES |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Finds a
Preference based on its key.
| |||||||||||
Returns the context.
| |||||||||||
Gets a SharedPreferences instance that points to the default file that is
used by the preference framework in the given context.
| |||||||||||
Returns the
PreferenceManager.OnNavigateToScreenListener , if one has been set.
| |||||||||||
Returns the root of the preference hierarchy managed by this class.
| |||||||||||
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 callback to be invoked when a
PreferenceScreen in the hierarchy rooted at
this PreferenceManager is clicked.
| |||||||||||
Sets the callback to be invoked when a
Preference in the
hierarchy rooted at this PreferenceManager is clicked.
| |||||||||||
Sets the root of the preference hierarchy.
| |||||||||||
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.
| |||||||||||
Called when a preference requests that a dialog be shown to complete a user interaction.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
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. |
---|
Returns the PreferenceManager.OnNavigateToScreenListener
, if one has been set.
Returns the root of the preference hierarchy managed by this class.
PreferenceScreen
object that is at the root of the hierarchy.
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 callback to be invoked when a PreferenceScreen
in the hierarchy rooted at
this PreferenceManager
is clicked.
listener | The callback to be invoked. |
---|
Sets the callback to be invoked when a Preference
in the
hierarchy rooted at this PreferenceManager
is clicked.
listener | The callback to be invoked. |
---|
Sets the root of the preference hierarchy.
preferenceScreen | The root PreferenceScreen of the preference hierarchy. |
---|
PreferenceScreen
given is different than the previous.
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. |
---|
Called when a preference requests that a dialog be shown to complete a user interaction.
preference | The preference requesting the dialog. |
---|