PreferenceManager
open class PreferenceManager
kotlin.Any | |
↳ | androidx.preference.PreferenceManager |
Used to help create Preference
hierarchies from activities or XML.
In most cases, clients should use PreferenceFragmentCompat#addPreferencesFromResource(int)
.
Summary
Nested classes | |
---|---|
abstract |
Interface definition for a class that will be called when a |
abstract |
Interface definition for a class that will be called when a |
abstract |
Interface definition for a callback to be invoked when a |
abstract |
Callback class to be used by the |
open |
A basic implementation of |
Constants | |
---|---|
static String |
Public methods | |
---|---|
open PreferenceScreen! |
createPreferenceScreen(context: Context!) |
open T? |
findPreference(@NonNull key: CharSequence) Finds a |
open Context! |
Returns the context. |
open static SharedPreferences! |
Gets a |
open PreferenceManager.OnDisplayPreferenceDialogListener! | |
open PreferenceManager.OnNavigateToScreenListener! |
Returns the |
open PreferenceManager.OnPreferenceTreeClickListener! | |
open PreferenceManager.PreferenceComparisonCallback! | |
open PreferenceDataStore? |
Returns the |
open PreferenceScreen! |
Returns the root of the preference hierarchy managed by this class. |
open SharedPreferences! |
Gets a |
open Int |
Returns the current mode of the |
open String! |
Returns the current name of the |
open Boolean |
Indicates if the storage location used internally by this class is the default provided by the hosting |
open Boolean |
Indicates if the storage location used internally by this class is backed by device-protected storage. |
open static Unit |
setDefaultValues(context: Context!, resId: Int, readAgain: Boolean) Sets the default values from an XML preference file by reading the values defined by each |
open static Unit |
Similar to |
open Unit |
setOnDisplayPreferenceDialogListener(onDisplayPreferenceDialogListener: PreferenceManager.OnDisplayPreferenceDialogListener!) |
open Unit |
Sets the callback to be invoked when a |
open Unit |
Sets the callback to be invoked when a |
open Unit |
setPreferenceComparisonCallback(preferenceComparisonCallback: PreferenceManager.PreferenceComparisonCallback!) |
open Unit |
setPreferenceDataStore(dataStore: PreferenceDataStore!) Sets a |
open Boolean |
setPreferences(preferenceScreen: PreferenceScreen!) Sets the root of the preference hierarchy. |
open Unit |
Sets the mode of the |
open Unit |
Sets the name of the |
open Unit |
Sets the storage location used internally by this class to be the default provided by the hosting |
open Unit |
Explicitly set the storage location used internally by this class to be device-protected storage. |
open Unit |
showDialog(preference: Preference!) Called when a preference requests that a dialog be shown to complete a user interaction. |
Constants
KEY_HAS_SET_DEFAULT_VALUES
static val KEY_HAS_SET_DEFAULT_VALUES: String
Value: "_has_set_default_values"
Public methods
createPreferenceScreen
open fun createPreferenceScreen(context: Context!): PreferenceScreen!
findPreference
@Nullable open fun <T : Preference!> findPreference(@NonNull key: CharSequence): T?
Finds a Preference
with the given key. Returns null
if no Preference
could be found with the given key.
Parameters | |
---|---|
key |
CharSequence: The key of the Preference to retrieve |
Return | |
---|---|
T? |
The Preference with the key, or null |
getDefaultSharedPreferences
open static fun getDefaultSharedPreferences(: Context!): SharedPreferences!
Gets a SharedPreferences
instance that points to the default file that is used by the preference framework in the given context.
Parameters | |
---|---|
context |
Context!: The context of the preferences whose values are wanted |
Return | |
---|---|
SharedPreferences! |
A SharedPreferences instance that can be used to retrieve and listen to values of the preferences |
getOnDisplayPreferenceDialogListener
open fun getOnDisplayPreferenceDialogListener(): PreferenceManager.OnDisplayPreferenceDialogListener!
getOnNavigateToScreenListener
open fun getOnNavigateToScreenListener(): PreferenceManager.OnNavigateToScreenListener!