Skip to content

Repository files navigation

CrossProcessPreferences

SharedPreferences's MULTI_PROCESS_MODE has been deprecated in API 23 for being not so reliable. Thus if you want to use SharedPreferences in multiple processes then you can use this.

NuGet

CrossProcessPreferencesNuGet

How to use it

It has an easy API that is similar to the one in SharedPreferences and works using a ContentProvider that must be registered in the AndroidManifest:

<applicationandroid:label="MyProject"android:icon="@mipmap/ic_launcher">
<providerandroid:name="crossprocesspreferences.PreferenceProvider"android:authorities="crossprocesspreferences.PreferenceProvider"android:exported="false" />
</application>

Then you can use it like this:

varpreferences=newCrossProcessSharedPreferences(this.Context,"myPreferencesName");preferences.SetPrefString("myKey","myValue");varvalueOfMyKey=preferences.GetPrefString("myKey","defaultValue");varisMyKeyStored=preferences.HasKey<string>("myKey");// remove the key from the preferencespreferences.Remove("myKey");

It supports int, long, bool (also if they are nullable), string and DateTime (it will store it as UTC).

Roadmap

  • Add support for decimal, double

About

It allows to have a Xamarin.Android ISharedPreferences to work cross process through a ContentProvider. Xamarin port based on https://github.com/DozenWang/DPreference

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages