Android Guides | Samples

Android.Content.ISharedPreferences

Interface for accessing and modifying preference data returned by Context.GetSharedPreferences(String,FileCreationMode).

See Also: ISharedPreferences

Syntax

[Android.Runtime.Register("android/content/SharedPreferences", "", "Android.Content.ISharedPreferencesInvoker")]
public interface ISharedPreferences : IJavaObject, IDisposable

Remarks

Interface for accessing and modifying preference data returned by Context.GetSharedPreferences(String,FileCreationMode). For any particular set of preferences, there is a single instance of this class that all clients share. Modifications to the preferences must go through an ISharedPreferencesEditor object to ensure the preference values remain in a consistent state and control when they are committed to storage. Objects that are returned from the various get methods must be treated as immutable by the application.

Note: currently this class does not support use across multiple processes. This will be added later.

Developer Guides

For more information about using SharedPreferences, read the Data Storage developer guide.

See Also

[Android Documentation]

Requirements

Namespace: Android.Content
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Content.ISharedPreferences are listed below.

Public Properties

[read-only]
AllIDictionary<string, object>. Retrieve all values from the preferences.

Public Methods

Contains(String) : Boolean
Checks whether the preferences contains a preference.
Edit() : ISharedPreferencesEditor
Create a new Editor for these preferences, through which you can make modifications to the data in the preferences and atomically commit those changes back to the SharedPreferences object.
GetBoolean(String, Boolean) : Boolean
Retrieve a boolean value from the preferences.
GetFloat(String, Single) : Single
Retrieve a float value from the preferences.
GetInt(String, Int32) : Int32
Retrieve an int value from the preferences.
GetLong(String, Int64) : Int64
Retrieve a long value from the preferences.
GetString(String, String) : String
Retrieve a String value from the preferences.
GetStringSet(String, ICollection<string>) : ICollection<string>
RegisterOnSharedPreferenceChangeListener(ISharedPreferencesOnSharedPreferenceChangeListener)
Registers a callback to be invoked when a change happens to a preference.
UnregisterOnSharedPreferenceChangeListener(ISharedPreferencesOnSharedPreferenceChangeListener)
Unregisters a previous callback.