PreferenceManager
Used to help create Preference hierarchies from activities or XML.
In most cases, clients should use addPreferencesFromResource.
See also
Types
Link copied to clipboard
interface OnDisplayPreferenceDialogListener
Interface definition for a class that will be called when a Preference requests to display a dialog.
Link copied to clipboard
interface OnNavigateToScreenListener
Interface definition for a class that will be called when a PreferenceScreen requests navigation.
Link copied to clipboard
interface OnPreferenceTreeClickListener
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.
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
Link copied to clipboard
Returns the PreferenceManager.OnNavigateToScreenListener, if one has been set.
Link copied to clipboard
Link copied to clipboard
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
open fun inflateFromResource(@NonNull context: Context, resId: Int, @Nullable rootPreferences: PreferenceScreen): PreferenceScreen
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
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
open fun setOnDisplayPreferenceDialogListener(@Nullable onDisplayPreferenceDialogListener: PreferenceManager.OnDisplayPreferenceDialogListener)
Link copied to clipboard
open fun setOnNavigateToScreenListener(@Nullable listener: PreferenceManager.OnNavigateToScreenListener)
Sets the callback to be invoked when a PreferenceScreen in the hierarchy rooted at this PreferenceManager is clicked.
Link copied to clipboard
open fun setOnPreferenceTreeClickListener(@Nullable listener: PreferenceManager.OnPreferenceTreeClickListener)
Sets the callback to be invoked when a Preference in the hierarchy rooted at this PreferenceManager is clicked.
Link copied to clipboard
open fun setPreferenceComparisonCallback(@Nullable preferenceComparisonCallback: PreferenceManager.PreferenceComparisonCallback)
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
Sets the root of the preference hierarchy.
Link copied to clipboard
Sets the mode of the SharedPreferences file that preferences managed by this will use.
Link copied to clipboard
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
Called when a preference requests that a dialog be shown to complete a user interaction.