Book Image

Cross-platform UI Development with Xamarin.Forms

By : Paul Johnson
Book Image

Cross-platform UI Development with Xamarin.Forms

By: Paul Johnson

Overview of this book

Table of Contents (22 chapters)
Cross-platform UI Development with Xamarin.Forms
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
In the Beginning…
Index

The database helper class


All smart phones come with a version of SQLite installed (including the likes of the Blackberry range), and while SQLite provides a number of inbuilt methods of storing data, they are often cumbersome and in terms of what they do (or how they do it), aren't exactly clear.

The second problem is that the connection has to be made every time a query is to be made.

Thankfully, it is more than possible to write a helper class that deals with the creation, insertion, amendment, and retrieval of data.

There are a number of advantages to having a helper class in this situation:

  • All the data methods are in one place (reducing the number of times code has to be written; therefore, less opportunity for error)

  • Potential for commonality of code to be reduced, making the database footprint smaller

  • Data retrieval can be made simpler

  • Lends well to generic types and optimization of the retrieval of data

Generic types within the helper class

While it is always useful to have, say, a method...