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.
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.
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.
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 .
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); } } }
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With