How to save / cache data in a cross-platform Mono application (e.g. Xamarin Framework)?

I am looking for a good solution for storing and / or caching data in a cross-platform application developed in C # (Xamarin MonoTouch and MonoDroid + WindowsPhone). Simple key / value pairs will suffice. The saved data will be used as general caching and as persistence to show something when the application starts, while new data is retrieved from the server.

Akavache looks very similar to what I want, but how to integrate it into my projects? Will he choose the right storage path? Are there similar libraries?

+6
source share
3 answers

I did not try the Akavache plane, but rather implemented a cross-platform wrapper around the preference APIs on Android and iOS:

var storage = SimpleStorage.EditGroup("group name of key/value store"); storage.Put("myKey", "some value"); var value = storage.Get("myKey"); 

The project is hosted on GitHub and distributed as a free NuGet Package . Along with storing the string, it also provides async / await and serialization / deserialization of complex objects.

+6
source

I would recommend just using XmlSerializer or something you used to use in .Net. You can simply change the file save path depending on the platform.

Akavache looks promising, but it looks a bit crowded if you need a pair of key-value pairs.

0
source

Akavache will automatically install the correct paths on both iOS and Android, it will use the information from your application (from AndroidManifest.xml on Android and your info.plist on iOS).

0
source

Source: https://habr.com/ru/post/921947/


All Articles