Implementing Content Providers

We've discussed how to interact with a content provider for data needs but haven't yet discussed how to write a content provider. To write a content provider, you have to extend android.content.ContentProvider and implement the following key methods:

query insert update delete getType

You'll also need to set up a number of things before implementing them. We will illustrate all the details of a content-provider implementation by describing the steps you'll need to take:

  1. Plan your database, URIs, column names, and so on, and create a metadata class that defines constants for all of these metadata elements.
  2. Extend the abstract class ContentProvider.
  3. Implement these methods: query, insert, update, delete, and

Get Pro Android 4 now with O’Reilly online learning.

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