Reputation: 139
I've read Android dev guide and notice that we can implement different classes for the content provider. So,
Here is what I read from the dev guide:
You implement a provider as one or more classes in an Android application
http://developer.android.com/guide/topics/providers/content-provider-creating.html
Upvotes: 4
Views: 6623
Reputation: 4712
There is no rule as such that you have to implement only one content provider per application. If your project demands, then you can do so.
If you want to implement multiple content providers in your application package, then make sure that authorities part of each content provider is unique, to route the incoming data requests to each content providers properly.
But having too many content providers can really confuse you and not required. The only scenario that I see to have multiple content providers is, if you are having multiple databases in your application and you want to share all those databases with outside applications. Where you can use separate content provider for each database to share it with outside world.
Hope it helps.
Upvotes: 1
Reputation: 1051
You can implement as many as you want, as you can see from the documentation here. To register a content provider, you need to add its corresponding <provider>
tag in the Android Manifest.
In most cases, however, you won't need multiple content providers. One is usually enough, as it can handle multiple tables. You should only really need more than one if you want your app to provide public access to 2+ separate data entities.
Upvotes: 6
Reputation: 1704
I suggest you first read those pages. Google is giving some more information about Content Providers, tutorials and examples:
Upvotes: 1
Reputation: 4705
You can use (provide as well as use) as many content providers per app as you need. They need different content URIs, of course.
In addition to the uses outlined in the document (your link) you can use content providers for other purposes as accessing data storage. The content URI can have parameters, so you can use a content provider similarly to a web service.
Upvotes: 1