I'm building a new project using Xamarin.Forms and I wanted to use SQLite to store the user data. I'm using .Net standard project. I installed the sqlite-net-pcl NuGet package by Frank A. Krueger in all 4 projects (shared code, droid, ios and uwp). I created the IFileHelper interface and the class implementing that interface in all projects, just as the documentation tells you to do. When I first launch the app I want to insert some default values in the database, but I just get an exception. I've been debugging and when the database is created on the App.xaml.cs doc it just returns null, so I don't get any database.
I've checked all code over and over and everything is fine, so I'm just wondering is sqlite-net-pcl compatible with .NET standard projects? Is there any solution for this prob?
This is the code on App.xaml.cs
static AppDatabase database;
    public App ()
    {
        InitializeComponent();
        MainPage = new MainPage();
    }
    public static AppDatabase Database
    {
        get
        {
            if (database == null)
            {
                database = new AppDatabase(DependencyService.Get<IFileHelper>().GetLocalFilePath("AppDatabase.db3"));
                System.Threading.Thread.Sleep(500);
            }
            return database;
        }
    }
I when I return the database, it just returns null, so when I create the table on the AppDatabase class, I get the exception System.AggregateException: One or more errors occurred.
readonly SQLiteAsyncConnection Database;
        public AppDatabase(string dbPath)
        {
            Database = new SQLiteAsyncConnection(dbPath);
            Database.CreateTableAsync<Stats>().Wait();
        }
I understand the exception, since the database is null I can't aggregate any table or anything at all since the database doesn't exist, but why it doesn't create the database?
This is the interface for the shared code
namespace FitApp
{
    public interface IFileHelper
    {
        string GetLocalFilePath(string fileName);
    }
}
And the class implementing the interface on the droid project:
[assembly: Dependency(typeof(FitApp.Droid.FileHelper))]
namespace FitApp.Droid
{
    public class FileHelper : IFileHelper
    {
        public string GetLocalFilePath(string fileName)
        {
            string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            return System.IO.Path.Combine(path, fileName);
        }
    }
}
Thanks
 
    