[英]Xamarin iOS: Can't fetch record from private database in icloud
Want to save a asset to the private database but.... ...my output says every launch "creating file...", so where's the problem at my code? 想要将资产保存到私有数据库,但是.......我的输出显示每次启动时“正在创建文件...”,所以我的代码出了什么问题? :( (uploading/saving seems to work because "uploaded" appears) :((由于显示“已上传”,因此上载/保存似乎可以正常工作)
var recordID = new CKRecordID("diary");
AppleHelper.PrivateDatabase.FetchRecord(recordID, (record, err) => {
// Was there an error?
if (err != null) {
Console.WriteLine(err.ToString());
Console.WriteLine("creating file...");
var dbName = "diary.db";
var dbPath = Path.Combine(documents.Path, dbName);
AppDelegate.lib.Conn = new SQLite.SQLiteConnection (dbPath);
AppDelegate.lib.Conn.CreateTable<LibChemotherapie.Diary> ();
if (File.Exists (dbPath)) {
var assetRecord = new CKRecord ("sqlite");
var db = new CKAsset(NSUrl.CreateFileUrl(new string[] { dbPath }));
assetRecord ["diary"] = db;
AppleHelper.PrivateDatabase.SaveRecord (assetRecord, (record2, err2) => {
if(err2 == null)
Console.WriteLine("uploaded");
});
}
}
else {
Console.WriteLine("yeah exists");
}
});
Thank you, I solved the problem. 谢谢,我解决了问题。 I could not fetch the record that I stored. 我无法获取存储的记录。 The problem was, that I used not the RecordID for loading, which I used for saving. 问题是,我没有使用RecordID进行加载,而是将其用于保存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.