Xamarin forms newbie here, and I am trying to establish an SQLite connection so that I may interact with a created database in my application.
I get no flags on this in the IDE, but when I compile, I'm getting a null reference error! Specifically, my _SQLiteConnection var is null, and I think it may have something to do with not setting the path properly?
I've referenced a few guides on doing this online, and although a little dated, they go about setting this up in the same manner I am.
Heres some code:
UserDb.cs:
using PluralBuddy.Models;
using SQLite;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace PluralBuddy.Data
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public class UserDB
{
private SQLiteConnection _SQLiteConnection;
public UserDB()
{
_SQLiteConnection = DependencyService.Get<ISQLiteInterface>().GetConnection();
_SQLiteConnection.CreateTable<User>();
}
ISQLiteInterface.cs:
using SQLite;
namespace PluralBuddy.Models
{
public interface ISQLiteInterface
{
SQLiteConnection GetConnection();
}
}
References:
https://code.tutsplus.com/tutorials/an-introduction-to-xamarinforms-and-sqlite--cms-23020
https://dzone.com/articles/register-and-login-using-sqlite-in-xamarinforms
As always, any help is appreciated!


DependencyService.Get<ISQLiteInterface>()check that this does not returnnull. If it is check how you handle the registration. - Guru StronISimService, and achieve thisISimServiceinterface bySimNumberclass, I need set the attribute is[assembly: Dependency(typeof(SimNumber))]like this sceenshot. imgur.com/a/sfIhDDS - Leon Lu - MSFT