【发布时间】:2016-06-22 22:02:06
【问题描述】:
对不起,如果之前有人问过这个问题,但我很好地搜索了这个问题,但我没有找到答案。
我在我的 Xamarin 表单项目 (PCL) 中使用 SQLite 处理本地数据库。
1- 连接在 iOS 中运行良好,但在 android 中我遇到了这个问题 (无法打开数据库文件)
- 我还设置了“ReadExternalStorage”和“WriteExternalStorage”权限。
2- 我使用了另一种创建连接路径的方法:
string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
string path = Path.Combine(documentsPath, "pbcare.db");
这样处理数据库时发生异常...
public bool checkLogin (string email, string password)
{
if (DB.Table<User> ().Where (user => user.Email == email && user.Password == password)
.FirstOrDefault () != null) { // exception caught here
return true;
} else {
return false;
}
}
但该表在数据库中。
注意:即使数据库文件不存在,第二种方式也会创建连接!
【问题讨论】:
标签: c# database sqlite xamarin xamarin.forms