This recipe demonstrates how to set up a cross-platform Xamarin.Forms solution to use SQLite and create the core most important object: a SQLite connection.
Create a Blank App (Xamarin.Forms Portable) named
XamFormsSQLiteDataAccess
in Visual Studio from File | New | Project…For each project, we will add two NuGet packages:
SQLite.Net-PCL
andSQLite.Net.Async-PCL
, a cross-platform SQLite client and ORM. Right-click in theXamFormsSQLiteDataAccess
portable core library and choose Manage NuGet Packages, search for the packages, and add them.Repeat step two for the Android, iOS, and Windows Phone projects.
iOS and Android support SQLite out of the box, whereas Windows Phone needs an extra step. Go to the Visual Studio top menu and click Tools | Extensions and Updates and search for
sqlite for windows phone
. In the results returned, choose the extension SQLite for Windows Phone.In the Windows Phone project, right-click the
References
folder and...