Get a list of available Content Providers

Viewed 36323

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.

6 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);
            }
        }
    }

I used adb shell command like this $ adb shell dumpsys > dumpsys.txt and search for content providers string in the output file. From that i can see the list of content providers in the device/emulator.

The list of registered content providers can be gathered with:

adb shell dumpsys package providers

Tested on Android 8.1 Oreo

Related