PreferenceManager

Used to help create Preference hierarchies from activities or XML.

In most cases, clients should use addPreferencesFromResource.

See also

Constructors

Link copied to clipboard
constructor(@NonNull context: Context)
Used by Settings.

Types

Link copied to clipboard
Interface definition for a class that will be called when a Preference requests to display a dialog.
Link copied to clipboard
Interface definition for a class that will be called when a PreferenceScreen requests navigation.
Link copied to clipboard
Interface definition for a callback to be invoked when a Preference in the hierarchy rooted at this PreferenceScreen is clicked.
Link copied to clipboard
Callback class to be used by the androidx.recyclerview.widget.RecyclerView.Adapter associated with the PreferenceScreen, used to determine when two Preference objects are semantically and visually the same.
Link copied to clipboard
A basic implementation of PreferenceComparisonCallback suitable for use with the default Preference classes.

Properties

Link copied to clipboard
val KEY_HAS_SET_DEFAULT_VALUES: String = "_has_set_default_values"

Functions

Link copied to clipboard
Link copied to clipboard
Finds a Preference with the given key.
Link copied to clipboard
Returns the context.
Link copied to clipboard
Gets a SharedPreferences instance that points to the default file that is used by the preference framework in the given context.
Link copied to clipboard
Returns the PreferenceDataStore associated with this manager or null if the default SharedPreferences are used instead.
Link copied to clipboard
Returns the root of the preference hierarchy managed by this class.
Link copied to clipboard
Gets a SharedPreferences instance that preferences managed by this will use.
Link copied to clipboard
Returns the current mode of the SharedPreferences file that preferences managed by this will use.
Link copied to clipboard
Returns the current name of the SharedPreferences file that preferences managed by this will use.
Link copied to clipboard
Inflates a preference hierarchy from XML.
Link copied to clipboard
Indicates if the storage location used internally by this class is the default provided by the hosting Context.
Link copied to clipboard
Indicates if the storage location used internally by this class is backed by device-protected storage.
Link copied to clipboard
open fun setDefaultValues(@NonNull context: Context, resId: Int, readAgain: Boolean)
Sets the default values from an XML preference file by reading the values defined by each Preference item's android:defaultValue attribute.
open fun setDefaultValues(@NonNull context: Context, sharedPreferencesName: String, sharedPreferencesMode: Int, resId: Int, readAgain: Boolean)
Similar to setDefaultValues but allows the client to provide the filename and mode of the shared preferences file.
Link copied to clipboard
Sets the callback to be invoked when a PreferenceScreen in the hierarchy rooted at this PreferenceManager is clicked.
Link copied to clipboard
Sets the callback to be invoked when a Preference in the hierarchy rooted at this PreferenceManager is clicked.
Link copied to clipboard
Sets a PreferenceDataStore to be used by all preferences associated with this manager that don't have a custom PreferenceDataStore assigned via setPreferenceDataStore.
Link copied to clipboard
open fun setPreferences(preferenceScreen: PreferenceScreen): Boolean
Sets the root of the preference hierarchy.
Link copied to clipboard
open fun setSharedPreferencesMode(sharedPreferencesMode: Int)
Sets the mode of the SharedPreferences file that preferences managed by this will use.
Link copied to clipboard
open fun setSharedPreferencesName(sharedPreferencesName: String)
Sets the name of the SharedPreferences file that preferences managed by this will use.
Link copied to clipboard
Sets the storage location used internally by this class to be the default provided by the hosting Context.
Link copied to clipboard
Explicitly set the storage location used internally by this class to be device-protected storage.
Link copied to clipboard
open fun showDialog(@NonNull preference: Preference)
Called when a preference requests that a dialog be shown to complete a user interaction.