Samsung/Tizen-CSharp-Samples

Sqlite

Ben-EJ opened this issue · 1 comments

Hi I attempted to recreate your "SQLite.NET.Sample" for practice yet I get this "error" (although it is not flagged as one the app does not open and debugging stops)

Error:
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();
            

Managed to solve it myself.

Was using the wrong version of these two dependencies:
SQLitePCLRaw.bundle_sqlite3
sqlite-net-pcl

you need to use:
sqlite-net-pcl Version : 1.8.0-beta
SQLitePCLRaw.bundle_sqlite3 Version : 2.0.5-pre20201231105030