我试图使用Xamarin上的sqlite,并已实现sqlite-net-pcl创建和访问本地数据库。在Android上工作得很好,但我不能在iOS上阅读记录。
Experiences experience = new Experiences()
{
Experience = experienceEntry.Text
};
//************************************
string folderPath = Path.Combine(
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)
, ".." /* This is not used on Android */
, "Library" /* This is not used on Android */
);
string fullPath = Path.Combine(folderPath, App.DB_FILE_NAME);
//************************************
SQLiteConnection conn = new SQLiteConnection(fullPath);
conn.CreateTable<Experiences>();
int rows = conn.Insert(experience);
var x = conn.Table<Experiences>();
conn.Close();
if (rows > 0)
DisplayAlert("Success", "Experience succesfully inserted", "Ok");
else
DisplayAlert("Failed", "Experience failed to be inserted", "Ok");
字符串
体验课程
public class Experiences
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[MaxLength(250)]
public string Experience { get; set; }
}
型
添加记录后,显示警报“成功”,但x值为空。
我怎么能读记录?我确实尝试了不同的文件夹和conn.Query而不是conn.Table,但我得到了相同的结果。
是否与权限有关?如果为真,为什么不能得到错误?
1条答案
按热度按时间5lwkijsr1#
这在iOS中适用
字符串