O'Reilly logo

Cross-platform UI Development with Xamarin.Forms by Paul F. Johnson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing your PCL library

For this, I'll use my DBManager class. It is simple to understand and see how things change. The source for this is included in the code examples.

Examining the code

The class itself starts by creating the database. This is performed by creating a database file on the device's storage. As this requires access to the filesystem, it will need to be handled in the platform code.

The majority of the code from thereon can be handled by the PCL.

Wait. The class works by using a connection string that is created when the database is created. The connection string can be accessed by an interface and then uses the dependency injection to place the connection string in the query.

The following is an old version of the code:

using SQLite; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required