0
我想要打開或創建(如果不存在)數據庫文件,但是當我嘗試創建SQLiteConnection類的新實例時,它拋出一個帶有錯誤代碼30的Exception(誤用)amd無法打開數據庫文件。Xamarin.Android SQLiteConnection無法打開數據庫文件
這裏是我的代碼:
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.
}
在變量上面的代碼中設置好的以下路徑:
/data/data/<AppName>.<AppName>/files/noNameFree.db3
我看不出有什麼我所著錯了。我希望有人看到代碼的問題。