Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many content provider we can implement in one app?

I've read Android dev guide and notice that we can implement different classes for the content provider. So,

  1. There are many content providers or just one content provider in one Android app?
  2. How to properly implement different content provider classes like that?

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

like image 577
khigianguyen Avatar asked Oct 17 '25 05:10

khigianguyen


2 Answers

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.

like image 149
Adrian Monk Avatar answered Oct 18 '25 18:10

Adrian Monk


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.

like image 41
Stefan Avatar answered Oct 18 '25 19:10

Stefan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!