Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list of available Content Providers

Tags:

android

Is there a way to programmatically list all available content providers on a device? No real use case, I just thought it might be neat to see what apps I have installed on my phone that have exposed content providers.

like image 743
Mark B Avatar asked Jan 04 '10 19:01

Mark B


People also ask

How many content providers are there?

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.

Who are the content providers?

A Content Provider is someone who supplies material produced by someone else to the final consumers of it. The term can be applied to an individual or an organization and in both cases they act as an intermediary between the original creators of the work and the people who view or read it.

How do I access content providers?

Accessing a provider. When you want to access data in a content provider, you use the ContentResolver object in your application's Context to communicate with the provider as a client. The ContentResolver object communicates with the provider object, an instance of a class that implements ContentProvider .


2 Answers

It should be possible by calling PackageManager.getInstalledPackages() with GET_PROVIDERS.

EDIT: example:

    for (PackageInfo pack : getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS)) {         ProviderInfo[] providers = pack.providers;         if (providers != null) {             for (ProviderInfo provider : providers) {                 Log.d("Example", "provider: " + provider.authority);             }         }     } 
like image 120
Mirko N. Avatar answered Sep 20 '22 05:09

Mirko N.


From the command line, run:

adb shell dumpsys | grep Provider{

Note the opening brace. This will give you a short list of all the providers installed through various packages.

like image 22
Simon Guest Avatar answered Sep 22 '22 05:09

Simon Guest