共用方式為


ISharedPreferences Interface

Definition

Interface for accessing and modifying preference data returned by Context#getSharedPreferences.

[Android.Runtime.Register("android/content/SharedPreferences", "", "Android.Content.ISharedPreferencesInvoker")]
public interface ISharedPreferences : Android.Runtime.IJavaObject, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/content/SharedPreferences", "", "Android.Content.ISharedPreferencesInvoker")>]
type ISharedPreferences = interface
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Attributes
Implements

Remarks

Interface for accessing and modifying preference data returned by Context#getSharedPreferences. 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 Editor 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: This class provides strong consistency guarantees. It is using expensive operations which might slow down an app. Frequently changing properties or properties where loss can be tolerated should use other mechanisms. For more details read the comments on Editor#commit() and Editor#apply().

<em>Note: This class does not support use across multiple processes.</em>

<div class="special reference"> <h3>Developer Guides</h3>

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

</div>

Java documentation for android.content.SharedPreferences.

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.

Properties

All

Retrieve all values from the preferences.

Handle

Gets the JNI value of the underlying Android object.

(Inherited from IJavaObject)
JniIdentityHashCode

Returns the value of java.lang.System.identityHashCode() for the wrapped instance.

(Inherited from IJavaPeerable)
JniManagedPeerState

State of the managed peer.

(Inherited from IJavaPeerable)
JniPeerMembers

Member access and invocation support.

(Inherited from IJavaPeerable)
PeerReference

Returns a JniObjectReference of the wrapped Java object instance.

(Inherited from IJavaPeerable)

Methods

Contains(String)

Checks whether the preferences contains a preference.

Disposed()

Called when the instance has been disposed.

(Inherited from IJavaPeerable)
DisposeUnlessReferenced()

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

(Inherited from IJavaPeerable)
Edit()

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.

Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
GetBoolean(String, Boolean)

Retrieve a boolean value from the preferences.

GetFloat(String, Single)

Retrieve a float value from the preferences.

GetInt(String, Int32)

Retrieve an int value from the preferences.

GetLong(String, Int64)

Retrieve a long value from the preferences.

GetString(String, String)

Retrieve a String value from the preferences.

GetStringSet(String, ICollection<String>)

Retrieve a set of String values from the preferences.

RegisterOnSharedPreferenceChangeListener(ISharedPreferencesOnSharedPreferenceChangeListener)

Registers a callback to be invoked when a change happens to a preference.

SetJniIdentityHashCode(Int32)

Set the value returned by JniIdentityHashCode.

(Inherited from IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates) (Inherited from IJavaPeerable)
SetPeerReference(JniObjectReference)

Set the value returned by PeerReference.

(Inherited from IJavaPeerable)
UnregisterFromRuntime()

Unregister this instance so that the runtime will not return it from future Java.Interop.JniRuntime+JniValueManager.PeekValue invocations.

(Inherited from IJavaPeerable)
UnregisterOnSharedPreferenceChangeListener(ISharedPreferencesOnSharedPreferenceChangeListener)

Unregisters a previous callback.

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to