mercredi 19 août 2015

Xamarin iOS not finding path for sqlite database

I am working on an iOS app that needs to have a simple sqlite db. This is in a portable class library using Xamarin. In the code I'm attempting to get the connection to the DB, but I'm not sure where I should be placing the database in my project folder nor if the #if __ IOS__ is even working honestly, but I'm using based on the Xamarin docs here: http://bit.ly/1MxSYey

public static SQLiteConnection GetConnection()
{
    #if __IOS__
        var sqliteFilename = "messages.db";
        var docs = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
        var db = Path.Combine(docs, "..", "Library", sqliteFilename);
        return new SQLiteConnection(db);
    #endif
    return null;
}

Aucun commentaire:

Enregistrer un commentaire