我正在尝试在我的项目中跨多个线程使用SQLite数据库使用Xamarin论坛中讨论的方法。他们在其中创建了以下静态类:
我该如何添加
我尝试了以下代码,但由于不符合所需的方法签名而失败。
public static class Data {
static readonly string Path = System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "database.db");
static SQLite.SQLiteConnection connection;
public static SQLite.SQLiteConnection Connection
{
get {
if (connection == null) {
connection = new SQLiteConnection (Path,SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex , true);
}
return connection;
}
}
}
我正在尝试实现这个功能,但是我目前使用的连接方法具有不同的方法签名。我想这是因为我正在使用PCL。我目前使用以下方式进行连接:
SQLiteConnection db = new SQLiteConnection (new SQLitePlatformIOS (), AppController._dbPath, false, null);
我该如何添加
SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex
以便我可以像这样使用连接:new SQLiteConnection (Path,SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex , true)
我尝试了以下代码,但由于不符合所需的方法签名而失败。
_connection = new SQLiteConnection (new SQLitePlatformIOS (),Path,false,null,SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex);