Creating content providers

If an app wants to allow its data to be available to other apps on the devices, it needs a way to control access. Content providers can be used as a public endpoint to the data, but they allow the app to maintain control over the data.

How to do it...

Creating content providers allows us to share data with other apps in a uniform manner. It is, for the most part, straightforward. Let's take a look at the following steps:

  1. First, we inherit from the ContentProvider base type:
    public class NumberStringsContentProvider : ContentProvider { public override bool OnCreate () { } public override string GetType (Uri uri) { } public override ICursor Query ( Uri uri, string[] projection, string selection, string[] selectionArgs, string ...

Get Xamarin Mobile Development for Android Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.