【发布时间】:2016-10-20 09:31:08
【问题描述】:
我想打开或创建(如果不存在)数据库文件,但是当我尝试创建 SQLiteConnection 类的新实例时,它会抛出异常,错误代码为 30(误用)amd 无法打开数据库文件.
这是我的代码:
class DatabaseOpen
{
protected SQLiteConnection db;
... // Here are another attributes of the class, which is not relevant to the database connection.
public DatabaseOpen(String filename="noNameFree") // String filename = "noNameFree"
{
String dbPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
dbPath = Path.Combine(dbPath, filename+".db3");
Java.IO.File dbFile = Application.Context.GetDatabasePath(dbPath);
dbFile.Mkdirs();
var dbObject = new SQLiteConnection(dbPath);
db = dbObject;
}
... // Here are the other methods of the class which is not relevant to the database connection.
}
在上面的代码中,dbPath 变量设置为以下路径:
/data/data/<AppName>.<AppName>/files/noNameFree.db3
我看不出我写错了什么。我希望有人看到代码的问题。
【问题讨论】:
标签: android sqlite xamarin xamarin.android sqlite-net