2014-05-24 108 views
0

我有兩個項目 - 一個PCL(配置文件7)和一個Android應用程序(針對API ...但作爲一邊,我希望它的目標10)。Akavache無法打開數據庫文件

PCL已經從Nuget安裝了akavache。 Android應用安裝了akavache.sqlite3。對於後者,我還必須引用Rx-PlatformServices,以便項目能夠建立。

Android應用引用PCL。

上有默認的Android活動有線了作爲按鈕如下:

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

的PCL擁有以下代碼。

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; } 
} 

按下按鈕後,我得到以下錯誤。

[單]未處理的異常:[單] SQLite.SQLiteException:無法 打開數據庫文件:BlobCache/userblobs.db(CannotOpen)[單]在 SQLite.SQLiteConnection..ctor(System.String databasePath , SQLiteOpenFlags openFlags,布爾storeDateTimeAsTicks)[0x0006d]在 /Users/paul/github/Akavache/Akavache.Sqlite3/SQLite.cs:125 [單]
在SQLite.SQLiteConnectionWithoutLock..ctor (SQLite.SQLiteConnectionString的connectionString, SQLiteOpenFlags 標誌)[0x00000] /Users/paul/github/Akavache/Akavache.Sqlite3/SQLiteAsync.cs:344 [單]在SQLite.SQLiteConnectionPool + Entry..ctor (SQLite.SQLiteConnectionString的connectionString,SQLiteOpenFlags 標誌)[0x0000d]在 /Users/paul/github/Akavache/Akavache.Sqlite3/SQLiteAsync.cs:330 [單]在SQLite.SQLiteConnectionPool + c__AnonStorey14。 <> m__25 (的Int32 _)[0x00000]在 /Users/paul/github/Akavache/Akavache.Sqlite3/SQLiteAsync.cs:309 [單]在 System.Linq.Enumerable + c__Iterator10`2 [System.Int32 ,SQLite.SQLiteConnectionPool + Entry] .MoveNext()[0x00000] in:0 [mono] at System.C

我想知道它是否是某種安全問題。這一切都運行我的電話(銀河注2),我有root權限。

任何想法?

在此先感謝。

回答

1

這是當你問它一萬年,但你可能沒有設置應用程序名稱:

BlobCache.ApplicationName = "MyAppName"; 
+0

哈!謝謝保羅。看 - 這是一段時間後,我最終只是滾動自己的。儘管如此,我記得'知道'ApplicationName需要設置,所以我的直覺是它是別的。你可能是對的。 –

相關問題