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; public class DBManager { public DBManager() { SQLite3.Config(SQLite3.ConfigOption.Serialized); dbLock = new object(); pConnectionString = Path.Combine(AppDelegate.Self.ContentDirectory, "mydatabase.db"); connectionString...