Akavache does not save cache data between application reloads

I have a Xamarin Android project using a common PCL library, and I decided to use Akavache as a temporary data store (to save some simple information about the login state, so that I keep the relocation every time).

Therefore, I added the Akavache and Akavache.Sqlite3 nuget packages to the shared library (and to the Xamarin.Android project). I installed BlobCache.ApplicationName, even named EnsureInitialized(this does not seem to do more than write a message).

I applied the application to the device. I started it manually (so there is no data cleaning and preferences, etc.). Data is cached (and retrieved) while the application is running. It throws exceptions (as expected) if keys are missing. Everything works perfectly.

Then I closed the application (at one stage I even rebooted the phone). When I restarted it, the cache is either empty or reinitialized. In any case, everything that I cached was gone.

I looked in the debugger where the sqlite3 caching files are stored, and the application tells me what they apparently are in data/data/packagename/cache/xyzblobs.db. I can not see these files because they are in the internal directory of the system cache of application files / files, so I have no idea if they are cleared or not.

I have included WRITE_EXTERNAL_STORAGE (and READ_) permissions. No dice. I tried to use goals Secure, UserAccountand LocalMachine. Nada. None of them work.

While the application is running (or in memory), it behaves as expected. The moment the application leaves, the cache does so.

, , BlobStorage.Shutdown(). , , . , , .

: .Shutdown().Wait(), .

- ? , , , ​​ , Xamarin.

, Akavache, , -Xamarin-Android, . - xplat, , Akavache Just That.

: :

( "AppGlobal", )

public static class SharedAppGlobal
{
  static SharedAppGlobal()
  {
    BlobCache.ApplicationName = SharedAppConstants.SharedAkavacheCacheName;
    BlobCache.EnsureInitialized();
  }
}

, BlobCache, , Sqlite3 ( sqlite3.db )

get/set ,

currentCookie = await BlobCache.LocalMachine.GetObject<Cookie>("authCookie");

await BlobCache.LocalMachine.InsertObject("authCookie", cookie);

Akavache . , (Secure, UserAccount LocalMachine), .

. . ( , , ), . reset. . , .db.

. . , apk. , , , - db, , , .

- ? , , , .

.

:)

+4
3

, , .

, - , , , . .

, SQlitePersistentBlobCache, DB , , ,

GetExternalFilesDir(null).AbsolutePath + "test.db)

! , !

- , , .

github https://github.com/wislon/xam-akavache-test.

master BlobCache.

instantiate-blobcache SQlitePersistentBlobCache.

- , . , , , , , , , - .

+5

, / .

Visual Studio:

  • > > ( ) Xamarin > Android > /

Xamarin Studio:

  • (Windows) > > > Android > /

  • (OS X) Xamarin Studio > > > Android > / .

, !

+4

Xamarin Forms , :

  • SqlLite3 PCL, iOS Android.
  • Akavache PCL, iOS Android.
  • OnStart

    protected override void OnStart() {   //   BlobCache.ApplicationName = "AppName";   BlobCache.EnsureInitialized(); }

mainagioia ( mainagioia, , , ... ). /

0

All Articles