Book Image

Xamarin Blueprints

By : Michael Williams
Book Image

Xamarin Blueprints

By: Michael Williams

Overview of this book

Do you want to create powerful, efficient, and independent apps from scratch that will leverage the Xamarin framework and code with C#? Well, look no further; you’ve come to the right place! This is a learn-as-you-build practical guide to building eight full-fledged applications using Xamarin.Forms, Xamarin Android, and Xamarin iOS. Each chapter includes a project, takes you through the process of building applications (such as a gallery Application, a text-to-speech service app, a GPS locator app, and a stock market app), and will show you how to deploy the application’s source code to a Google Cloud Source Repository. Other practical projects include a chat and a media-editing app, as well as other examples fit to adorn any developer’s utility belt. In the course of building applications, this book will teach you how to design and prototype professional-grade applications implementing performance and security considerations.
Table of Contents (14 chapters)
Xamarin Blueprints
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Implementing the SQLiteStorage class


Now back to the FileStorage.Portable project. Let's add another file into the Storage folder called SQLiteStorage.cs and implement the private variables:

public class SQLiteStorage : ISQLiteStorage 
    {
        #region Private Properties
        private readonly AsyncLock asyncLock = new AsyncLock();
        private readonly object lockObject = new object();
        private SQLiteConnectionWithLock _conn;
        private SQLiteAsyncConnection _dbAsyncConn;
        private readonly ISQLitePlatform _sqlitePlatform;
        private string _dbPath;
        private readonly ILogger _log;
        private readonly string _tag;
        #endregion
    }

We have a private AsyncLock object as we will be doing synchronous and asynchronous locking implementations. We then have two SQLite objects for creating the connection to our local database. The _dbPath variable is used to hold the local database path; this will be used for setting up the connection. We also have...