IPreferenceDataStore Interface

Definition

A data store interface to be implemented and provided to the Preferences framework.

[Android.Runtime.Register("android/preference/PreferenceDataStore", "", "Android.Preferences.IPreferenceDataStoreInvoker", ApiSince=26)]
public interface IPreferenceDataStore : Android.Runtime.IJavaObject, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/preference/PreferenceDataStore", "", "Android.Preferences.IPreferenceDataStoreInvoker", ApiSince=26)>]
type IPreferenceDataStore = interface
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Attributes
Implements

Remarks

A data store interface to be implemented and provided to the Preferences framework. This can be used to replace the default android.content.SharedPreferences, if needed.

In most cases you want to use android.content.SharedPreferences as it is automatically backed up and migrated to new devices. However, providing custom data store to preferences can be useful if your app stores its preferences in a local db, cloud or they are device specific like "Developer settings". It might be also useful when you want to use the preferences UI but the data are not supposed to be stored at all because they are valid per session only.

Once a put method is called it is full responsibility of the data store implementation to safely store the given values. Time expensive operations need to be done in the background to prevent from blocking the UI. You also need to have a plan on how to serialize the data in case the activity holding this object gets destroyed.

By default, all "put" methods throw UnsupportedOperationException.

This member is deprecated. Use the AndroidX Preference Library for consistent behavior across all devices. For more information on using the AndroidX Preference Library see Settings.

Java documentation for android.preference.PreferenceDataStore.

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

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

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)
Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
GetBoolean(String, Boolean)

Retrieve a boolean value from the data store.

GetFloat(String, Single)

Retrieve a float value from the data store.

GetInt(String, Int32)

Retrieve an int value from the data store.

GetLong(String, Int64)

Retrieve a long value from the data store.

GetString(String, String)

Retrieve a String value from the data store.

GetStringSet(String, ICollection<String>)

Retrieve a set of String values from the data store.

PutBoolean(String, Boolean)

Set a boolean value to the data store.

PutFloat(String, Single)

Set a float value to the data store.

PutInt(String, Int32)

Set an int value to the data store.

PutLong(String, Int64)

Set a long value to the data store.

PutString(String, String)

Set a String value to the data store.

PutStringSet(String, ICollection<String>)

Set a set of String value to the data store.

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)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to