Jaa


Xamarin.iOS Data Access

Xamarin.iOS supports database access APIs such as:

  • ADO.NET framework.
  • SQLite-NET 3rd party library.

This guide provides a high-level overview of databases in general before describing how to set up ADO.NET and SQLite.NET to access SQLite databases in your Xamarin.iOS applications.

The majority of the code in this document is completely cross-platform and will run on iOS or Android without modification. There are two sample apps discussed:

  • DataAccess_Basic – Simple data operations writes the results to a text display control;
  • DataAccess_Advanced – Integrates data operations into a small working application that lists and edits a simple data structure.

Both sample solutions contain iOS and Android sample application projects.

For Xamarin.Forms applications, read working with databases which explains how to work with SQLite in a PCL library with Xamarin.Forms.

Sections

Summary

This chapter discussed data access in Xamarin.iOS using SQLite as the database engine. The database can be accessed “directly” using ADO.NET syntax or you can include the SQLite.NET ORM and perform data operations in C#.

We reviewed two samples: one that contains very simple data access code that outputs to a text field, and a simple application that includes create, read, update and delete functionality. We also discussed threading and how to seed your application with a pre-populated SQLite database.

For additional examples of cross-platform data access see our Tasky Pro case study.