How to Inspect Content Providers and Granted URI Permissions on Android Using ADB

In Android application architecture, Content Providers encapsulate structured data sets (such as SQLite databases, photos, contacts, and custom repository documents) and manage secure inter-process data sharing. Rather than exposing underlying database files directly to other apps, an application publishes a URI authority (e.g., content://com.example.provider/items) and grants temporary or persistent access using Android\u2019s URI permission model. When developing custom providers or troubleshooting SecurityException errors during file sharing, the Android Debug Bridge (ADB) provides powerful tools to inspect active providers, audit granted URI permissions, and query records directly from the command line.

Understanding Content Providers and the URI Permission Model

Content Providers act as standard abstractions over data layers:

  • Authorities: A unique string declared in the AndroidManifest.xml identifying the provider to the Android system (e.g., com.example.myapp.fileprovider).
  • URI Grants (FLAG_GRANT_READ_URI_PERMISSION): Allows an application to grant temporary read or write access for a specific URI to a target package without granting broad permission to the entire database.
  • Permission Modes: Persistent grants (stored in /data/system/urigrants.xml) remain active across device reboots until explicitly revoked.

Inspecting Registered Providers with dumpsys activity providers

To inspect all published Content Providers currently running on your connected Android device:

adb shell dumpsys activity providers

To filter the diagnostic output for a specific application package or authority:

adb shell dumpsys activity providers com.example.myapp

The command details provider state and published authorities:

Published content providers (by authority):
  * [com.example.myapp.provider]: ContentProviderRecord{7c41200 u0 com.example.myapp/.MyDataProvider}
    package=com.example.myapp process=com.example.myapp
    authority=com.example.myapp.provider
    readPermission=android.permission.READ_USER_DICTIONARY
    writePermission=android.permission.WRITE_USER_DICTIONARY
    multiprocess=false initOrder=0
    clients=[ProcessRecord{8d1200 1482:com.target.clientapp/u0a142}]

Key information revealed:

  • authority: Confirms the exact string needed to construct content URIs.
  • readPermission / writePermission: Identifies security gates required for third-party access.
  • clients: Lists all active processes currently bound to the provider.

Auditing Granted URI Permissions Across Applications

Security vulnerabilities often arise when applications inadvertently grant persistent URI permissions to third-party apps. To audit all active and persistent URI permission grants across the entire operating system:

adb shell dumpsys activity permissions

The output reports granted URIs grouped by owner and target packages:

Granted Uri Permissions:
  * User 0:
    Owner: com.example.myapp (uid 10184)
    Target: com.google.android.apps.photos (uid 10098)
    Source: content://com.example.myapp.fileprovider/shared_images/photo1.jpg
    Mode: read, persistent

This allows you to verify that temporary file shares correctly expire and do not expose unauthorized data to external apps.

Querying Content Providers Directly Using content query

ADB includes a built-in shell tool, content, which enables direct CRUD operations against published content providers without writing custom test code.

To query data from a content URI:

adb shell content query --uri content://com.example.myapp.provider/items

The command returns database rows in key-value format:

Row: 0 _id=1, title=Task One, status=completed
Row: 1 _id=2, title=Task Two, status=pending

You can also filter queries using standard SQL projection and selection clauses:

adb shell content query --uri content://com.example.myapp.provider/items --projection _id:title --where "status='completed'" --sort "title ASC"

Testing Data Insertion and Updates via ADB

To test how your content provider handles incoming records, execute an insert command:

adb shell content insert --uri content://com.example.myapp.provider/items --bind title:s:"New Task" --bind status:s:"pending"

To test record deletion:

adb shell content delete --uri content://com.example.myapp.provider/items --where "_id=2"

Using dumpsys activity providers in tandem with content query allows rapid end-to-end verification of Android data layers, permission boundaries, and database query performance.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.