Question

I'm looking for a good solution to store and/or cache data in a cross platform App developed in C# (Xamarin's MonoTouch & MonoDroid + WindowsPhone). Simple Key/Value Pairs would be sufficient. The stored data will to be used as general caching and as persistence to show something on App startup while new data is fetched from the server.

Akavache looks very much like what I want but how to integrate it in my projects? Will it choose the right path's for storing? Are there similar libraries around?

Was it helpful?

Solution

I have not tried Akavache jet but rather implemented a cross-plattform 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 string storing it also provides async/await methods and serializing/deserializing of complex objects.

OTHER TIPS

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

Akavache looks promising, but it looks a little overkill if you only need a couple key-value pairs.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top