Share via


PreferenceManager.SetDefaultValues Method

Definition

Overloads

SetDefaultValues(Context, Int32, Boolean)

Sets the default values from an XML preference file by reading the values defined by each Preference item's android:defaultValue attribute.

SetDefaultValues(Context, String, FileCreationMode, Int32, Boolean)

Similar to #setDefaultValues(Context, int, boolean) but allows the client to provide the filename and mode of the shared preferences file.

SetDefaultValues(Context, Int32, Boolean)

Sets the default values from an XML preference file by reading the values defined by each Preference item's android:defaultValue attribute.

[Android.Runtime.Register("setDefaultValues", "(Landroid/content/Context;IZ)V", "")]
public static void SetDefaultValues (Android.Content.Context? context, int resId, bool readAgain);
[<Android.Runtime.Register("setDefaultValues", "(Landroid/content/Context;IZ)V", "")>]
static member SetDefaultValues : Android.Content.Context * int * bool -> unit

Parameters

context
Context

The context of the shared preferences.

resId
Int32

The resource ID of the preference XML file.

readAgain
Boolean

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. <p class="note"> Note: this will NOT reset preferences back to their default values. For that functionality, use PreferenceManager#getDefaultSharedPreferences(Context) and clear it followed by a call to this method with this parameter set to true.

Attributes

Remarks

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.

Java documentation for android.preference.PreferenceManager.setDefaultValues(android.content.Context, int, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SetDefaultValues(Context, String, FileCreationMode, Int32, Boolean)

Similar to #setDefaultValues(Context, int, boolean) but allows the client to provide the filename and mode of the shared preferences file.

[Android.Runtime.Register("setDefaultValues", "(Landroid/content/Context;Ljava/lang/String;IIZ)V", "")]
public static void SetDefaultValues (Android.Content.Context? context, string? sharedPreferencesName, Android.Content.FileCreationMode sharedPreferencesMode, int resId, bool readAgain);
[<Android.Runtime.Register("setDefaultValues", "(Landroid/content/Context;Ljava/lang/String;IIZ)V", "")>]
static member SetDefaultValues : Android.Content.Context * string * Android.Content.FileCreationMode * int * bool -> unit

Parameters

context
Context

The context of the shared preferences.

sharedPreferencesName
String

A custom name for the shared preferences file.

sharedPreferencesMode
FileCreationMode

The file creation mode for the shared preferences file, such as android.content.Context#MODE_PRIVATE or android.content.Context#MODE_PRIVATE

resId
Int32

The resource ID of the preference XML file.

readAgain
Boolean

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. <p class="note"> Note: this will NOT reset preferences back to their default values. For that functionality, use PreferenceManager#getDefaultSharedPreferences(Context) and clear it followed by a call to this method with this parameter set to true.

Attributes

Remarks

Similar to #setDefaultValues(Context, int, boolean) but allows the client to provide the filename and mode of the shared preferences file.

Java documentation for android.preference.PreferenceManager.setDefaultValues(android.content.Context, java.lang.String, int, int, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to