MediaProvider module

The MediaProvider module optimizes indexed metadata (audio, video, and images from SD cards and USB devices) and makes that data available to apps through the MediaStore public APIs. To maintain user privacy, the MediaProvider module enforces the scoped storage security model introduced in Android 10, which includes redacting sensitive location metadata. This module is updatable, enabling Android to respond faster to security issues (keeping sensitive user data protected) and add new media formats quicker (providing consistency to both users and developers).

Changes in Android 10

Android 10 introduced several improvements related to identifying and extracting data from media files, specifically:

  • Determining the file content type using the first part of a file’s MIME type. For example, the OS knows that both image/png and image/x-newly-invented-format are images, and can thus accurately describe relevant permissions to the end user.

  • Determining the MIME type using only the file extension (and without using content sniffing to avoid security issues).

  • Determining the MIME type of an arbitrary file using a combination of upstream Debian Linux and Android mappings.

  • Returning relevant data from video/* and audio/* files (via MediaMetadataRetriever) and image/* files (via ExifInterface).

Changes in Android 11

In Android 11, the MediaProvider module builds on the changes made in Android 10 with the following improvements:

  • Improvements to indexing. The MediaProvider module now indexes metadata by reconciling available metadata against MediaStore public APIs. Changes include:

    • New is_favorite column and QUERY_ARG_MATCH_FAVORITE argument to enable gallery-style apps to quickly filter media based on this column.

    • Indexing color space metadata.

    • New 'is_trashed' column and QUERY_ARG_MATCH_TRASHED argument to enable gallery-style apps to filter based on this column.

    • New APIs that enable bulk-modification of multiple items with a single user dialog prompt, including createDeleteRequest(), createFavoriteRequest(), createTrashRequest(), and createWriteRequest().

    • New GENERATION_ADDED and GENERATION_MODIFIED columns for use in quickly and reliably detecting changes that have occurred since a previous synchronization point.

    • New GROUP BY public API for use with additional metadata columns not mentioned above.

  • Improvement to ExifInterface to extract metadata from PNG and WebP containers.

  • Improvements to SystemUI to write DateTimeOriginal metadata in screen captures.

In addition, you can now customize MediaProvider by adding new media formats, marking which storage devices should be indexed, and even replacing the MTP stack. For details, see Customization.

Module boundary

Android 11 migrates all code in packages/providers/MediaProvider to a new location, with the notable exception of MTP-related logic. In addition, frameworks/base/core/java/android/provider/ is now inside the module boundary at packages/providers/MediaProvider.

Package format

The MediaProvider module is in APK-in-APEX format.


MediaProvider dependencies are related to customizations (that is, if you customize MediaProvider, you must ensure your implementation meets the dependency associated with your customization).

  • When using custom or nonstandard media file formats (for example, a format generated by a vendor-specific Camera app), you must register each custom format with MimeUtils and the Media Extractor module to enable indexing by MediaProvider.

  • To ensure MediaProvider indexes a custom set of storage devices (such SD card slots and USB ports) used in a StorageManagerService implementation, set the VolumeInfo.MOUNT_FLAG_INDEXABLE flag.

  • When using a custom (non-AOSP) MTP implementation, ensure the implementation relies solely on public and system APIs to enable the implementation to interact with MediaStore.


You can now add new media formats, influence which storage devices are indexed, and replace the MTP stack.

  • Custom media formats. For each new custom media format, you must provide a mapping from the unique file extension to a MIME type. We strongly encourage you to follow the IANA registration process.

    • You can't redefine an extension or MIME type that's already defined in AOSP.

    • For video/* and audio/* files, MediaProvider continues consulting MediaMetadataRetriever. Use the Android 10 Media Extractors to return metadata for custom formats.

    • For image/* files, MediaProvider continues standardizing on Exif for metadata. You can extend to extract and return Exif metadata for any custom image formats.

  • Storage devices indexing flag. MediaProvider indexes all volumes returned by StorageManager.getStorageVolumes() where StorageVolume.getMediaStoreVolumeName() is non-null. You can customize the list of volumes returned to influence what is indexed, but we advise against including transient volumes (such as USB OTG drives).

  • MTP stack replacement. Android 11 places the MTP stack entirely outside the module boundary and ensures that it works against public APIs.


You can verify the functionality of MediaProvider using the following tests:

  • To verify the functionality of MediaStore public APIs, use tests in the CtsProviderTestCases package of the Android Compatibility Test Suite (CTS).

  • To verify the functionality of MediaProvider internals, use tests in MediaProviderTests.

To run both sets of tests together, use the following atest command:

atest --test-mapping packages/providers/MediaProvider