Akavache losing data in Xamarin.iOS

Akavache Logo
Akavache Logo - Image from https://github.com/reactiveui/Akavache

Today I am sharing an issue that I believe many have faced and probably tried resolving a lot. The issue is mostly seen when using Akavache in Xamarin.iOS (even when using Xamarin.Forms). The issue is this:

When using the App either in Simulator or Device, we try to use say Akavache’s BlobCache to store some data. During the runtime of the App, we tend to read the data back from the BlobCache and play with it. However, the real reason we use BlobCache is that we want to store some data like UserInformation, etc. to persist during App restarts.

But we see that the information is lost during the App restarts.

The main reason behind this is the Akavache is built to be used on top of SQLite. However, if the required plugin or rather the NuGet package is not found, the data is then persisted temporarily as the SQLite is not initialized for use with Akavache.

In order to fix this, I installed the NuGet Package SQLitePCLRaw.bundle_e_sqlite3 in all the projects.

The moment it got installed, I could see that my data was getting cached and persisted during the App restarts. I hope it helps.

Do ensure that you are initializing the Application Name:

BlobCache.ApplicationName = "AkavacheExperiment";

Happy Coding!

Anubhav Ranjan

Leave a Reply