Damien Sawyer
Damien Sawyer

Reputation: 5907

Akavache can not open database file

I have two projects - a PCL (profile 7) and an Android application (targeting API ... but as an aside I want it to target 10).

The PCL has installed akavache from Nuget. The Android app has installed akavache.sqlite3. For the latter I also had to reference Rx-PlatformServices so that the projects would build.

The Android app references the PCL.

There is a button on the default Android activity wired up as follows:

button.Click += async (sender, e) =>
{
    var d = new DataService();
    await d.SaveData();
    var ss = await d.LoadData();
    button.Text = ss;
};

The PCL has the following code.

public class DataService
{
    private IBlobCache blobStore;

    public DataService()
    {
        BlobCache.ApplicationName = "DamienApp";
        this.blobStore = BlobCache.UserAccount;
    }
    public async Task SaveData()
    {
        var data = new Person {Name = "Sienna", Age = 3};
        await this.blobStore
                    .InsertObject<string>("mykey", JsonConvert.SerializeObject(data));
    }

    public async Task<string> LoadData()
    {
        var data = await this.blobStore.GetObjectAsync<string>("mykey");
        return data;
    }
}

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}

On pressing the button I'm given the following error.

[mono] Unhandled Exception: [mono] SQLite.SQLiteException: Could not open database file: BlobCache/userblobs.db (CannotOpen) [mono] at SQLite.SQLiteConnection..ctor (System.String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks) [0x0006d] in /Users/paul/github/Akavache/Akavache.Sqlite3/SQLite.cs:125 [mono]
at SQLite.SQLiteConnectionWithoutLock..ctor (SQLite.SQLiteConnectionString connectionString, SQLiteOpenFlags flags) [0x00000] in /Users/paul/github/Akavache/Akavache.Sqlite3/SQLiteAsync.cs:344 [mono] at SQLite.SQLiteConnectionPool+Entry..ctor (SQLite.SQLiteConnectionString connectionString, SQLiteOpenFlags flags) [0x0000d] in /Users/paul/github/Akavache/Akavache.Sqlite3/SQLiteAsync.cs:330 [mono] at SQLite.SQLiteConnectionPool+c__AnonStorey14.<>m__25 (Int32 _) [0x00000] in /Users/paul/github/Akavache/Akavache.Sqlite3/SQLiteAsync.cs:309 [mono] at System.Linq.Enumerable+c__Iterator10`2[System.Int32,SQLite.SQLiteConnectionPool+Entry].MoveNext () [0x00000] in :0 [mono] at System.C

I'm wondering if it's some kind of security issue. This is all running my phone (Galaxy note 2) to which I have root access.

Any ideas?

Thanks in advance.

Upvotes: 0

Views: 791

Answers (1)

Ana Betts
Ana Betts

Reputation: 74654

This is a million years from when you asked it, but you probably didn't set the Application Name:

BlobCache.ApplicationName = "MyAppName";

Upvotes: 1

Related Questions