Implementing Content Providers

So we've discussed how to interact with a content provider for our 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

However, to make these methods work, you'll have 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 getType.

4. Register the provider in the manifest file.

0 0

Post a comment