I'm trying create a database on my application (Xamarin.Android). I'm using this tutorial http://developer.xamarin.com/recipes/android/data/databases/sqlite/
but the site don't explicate about parameter to path
on
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:
SQLite.SQLite3+Result.CannotOpen
The documentation for the Xamarin SQLite Component has an example of the correct path to use (under 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!");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.