SqliteConnection doesnt completely open database in Xamarin


I am new to Xamarin and so far it is great. However, I am now in my fifth day of banging my head against the wall trying to get a simple Sqlite database to open. I am testing this on an Android phone, Samsung Galaxy S5. I am using the NuGet sqlite-net-pcl 1.5.231.

In PluralSight and in many other examples I have seen on the Web this should work; and I haven't yet found anyone else experiencing this issue.

If anyone has any idea at all, I am ready to try it. My head really hurts!

When I issue the SQLiteConnection connection = new SQLiteConnection(path); the file gets opened (else I get a not found condition) but SQLite acts like the datebase is empty. It cant find the tables.

Of course Sqlite sensing that this is an empty database handles it as a new empty database and thus returns the error that 'No such table exists: SITE'.

If I run the same code in a Dot.Net Console app pointing to the PC copy of that same database it works fine.
If I inspect the database on the phone using 'SQLite Manager for Android' from the Play store, it looks fine.

I noticed that when inspecting the 'connection' variable right after its creation, there are two properties that are not initialized on the Xamarin example that are populated in the Dot.Net console app.

1) the BusyTimeout property is uninitialized on the Xamarin example while the Console App has a value.
2) the Tracer property is uninitialized on the Xamarin example while the Console App has a value.

These two differences are meaningless to the app; but perhaps some evidence that the connection is not fully completed .

public class Site
public string Name { get; set; }
public string Address { get; set; }

public partial class SitesPage : ContentPage

    SitesViewModel viewModel;
    public SitesPage ()
        InitializeComponent ();
        string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "KeyMaster.db");
        SQLiteConnection connection = new SQLiteConnection(path);
        List<Site> x = connection.Query<Site>("SELECT * FROM SITE");

        BindingContext = x;


  • LandLuLandLu Member, Xamarin Team Xamurai

    Where did you place your KeyMaster.db database? If you embedded it directly in your Android project. You have to copy it to your app's storage first, then use this path to read your database. Or

    string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "KeyMaster.db");

    This wan't get a existed file path.
    Follow this blog to check your path's validation:

Sign In or Register to comment.