O'Reilly logo

Pro Android 4 by Satya Komatineni, Dave MacLean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required