【发布时间】:2014-12-15 04:23:11
【问题描述】:
我在 android 平台上使用 sqlite-pcl 有一个非常奇怪的情况......我有一个从 SQLiteConnection 继承的数据库类,我为我的数据库使用个人文件夹,在构造函数中我有一个检查是否存在,但通常当我再次启动应用程序时,不删除任何文件,它返回 false...
public class ScannifyDatabase : SQLiteConnection
{
public static string DBPath
{
get
{
string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
return System.IO.Path.Combine(path, "Scaniff.db3");
}
}
public ScannifyDatabase(string path)
: base(new SQLitePlatformAndroid(),path)
{
if (!TableExists())
{
this.CreateTable<DocumentType>();
InitData();
}
}
private bool TableExists()
{
// return this.TableExists();
const string cmdText = "SELECT name FROM sqlite_master WHERE type='table' AND name=?";
var cmd = this.CreateCommand(cmdText, typeof(DocumentType).Name);
var res = !string.IsNullOrEmpty(cmd.ExecuteScalar<string>());
return res;
}
}
问题是什么?
【问题讨论】:
标签: sqlite xamarin xamarin.android android-sqlite