sqlite
Ben-EJ opened this issue · comments
Benjamin Ell-Jones commented
Hi I attempted to recreate your "SQLite.NET.Sample" but app just closes on start
debug stopped, stopping observer
Inside stop observer
flag observer value is : False
My code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using SQLite;
using System.IO;
namespace TimeTable
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public class Item
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string LessonName { get; set; }
public string Time { get; set; }
}
public partial class MainPage : ContentPage
{
const string databaseFileName = "TimeTableDB.db3";
SQLiteConnection dbConnection;
static string databasePath;
public void InitiateSQLite()
{
bool needCreateTable = false;
string dataPath = global::Tizen.Applications.Application.Current.DirectoryInfo.Data;
databasePath = Path.Combine(dataPath, databaseFileName);
if (!File.Exists(databasePath))
{
needCreateTable = true;
}
dbConnection = new SQLiteConnection(databasePath);
if (needCreateTable)
{
dbConnection.CreateTable<Item>();
}
Item item2 = new Item
{
Time = DateTime.Now.ToString(),
};
dbConnection.Insert(item2);
}
public MainPage()
{
InitializeComponent();
InitiateSQLite();
}
}
}
Thanks for any help provided.