简体   繁体   English

Visual Studio + Xamarin:创建数据库SQLite

[英]Visual Studio + Xamarin: Create database SQLite

I'm trying create a database on my application (Xamarin.Android). 我正在尝试在我的应用程序(Xamarin.Android)上创建数据库。 I'm using this tutorial http://developer.xamarin.com/recipes/android/data/databases/sqlite/ 我正在使用本教程http://developer.xamarin.com/recipes/android/data/databases/sqlite/

but the site don't explicate about parameter to path on 但该网站未提供有关path参数的详细说明

private string createDatabase(string path)
{
    try
    {
        var connection = new SQLiteAsyncConnection(path);{
             connection.CreateTableAsync<person>();
             return "Database created";
    }
    catch (SQLiteException ex)
    {
        return ex.Message;
    }
}

Can anyone help me, with this parameter? 有人可以用这个参数帮助我吗?

I try with "/app1/databases/dbPEduc.db" but show the Exception: 我尝试使用“ /app1/databases/dbPEduc.db”,但显示异常:

SQLite.SQLite3+Result.CannotOpen

The documentation for the Xamarin SQLite Component has an example of the correct path to use (under Asynchronous API ) Xamarin SQLite组件的文档提供了一个使用正确路径的示例(在Asynchronous API下

string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
var conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "stocks.db"));
conn.CreateTableAsync<Stock>().ContinueWith (t => {
    Console.WriteLine ("Table created!");
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM