MediaStore.MediaColumns  |  API reference  |  Android Developers (original) (raw)


public static interface MediaStore.MediaColumns
implements[BaseColumns](/reference/android/provider/BaseColumns)

android.provider.MediaStore.MediaColumns

Known indirect subclasses

MediaStore.Audio.AudioColumns, MediaStore.Audio.Genres.Members, MediaStore.Audio.Media, MediaStore.Audio.Playlists, MediaStore.Audio.Playlists.Members, MediaStore.Audio.PlaylistsColumns, MediaStore.DownloadColumns, MediaStore.Downloads, MediaStore.Files.FileColumns, MediaStore.Images.ImageColumns, MediaStore.Images.Media, MediaStore.Video.Media, MediaStore.Video.VideoColumns


Common media metadata columns.

Summary

Constants
String ALBUM Indexed value of MediaMetadataRetriever.METADATA_KEY_ALBUM extracted from this media item.
String ALBUM_ARTIST Indexed value of MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST extracted from this media item.
String ARTIST Indexed value of MediaMetadataRetriever.METADATA_KEY_ARTIST or ExifInterface.TAG_ARTIST extracted from this media item.
String AUTHOR Indexed value of MediaMetadataRetriever.METADATA_KEY_AUTHOR extracted from this media item.
String BITRATE Indexed value of MediaMetadataRetriever.METADATA_KEY_BITRATE extracted from this media item.
String BUCKET_DISPLAY_NAME The primary bucket display name of this media item.
String BUCKET_ID The primary bucket ID of this media item.
String CAPTURE_FRAMERATE Indexed value ofMediaMetadataRetriever.METADATA_KEY_CAPTURE_FRAMERATE extracted from this media item.
String CD_TRACK_NUMBER Indexed value ofMediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER extracted from this media item.
String COMPILATION Indexed value of MediaMetadataRetriever.METADATA_KEY_COMPILATION extracted from this media item.
String COMPOSER Indexed value of MediaMetadataRetriever.METADATA_KEY_COMPOSER extracted from this media item.
String DATA Absolute filesystem path to the media item on disk.
String DATE_ADDED The time the media item was first added.
String DATE_EXPIRES The time the media item should be considered expired.
String DATE_MODIFIED Indexed value of File.lastModified() extracted from this media item.
String DATE_TAKEN Indexed value of MediaMetadataRetriever.METADATA_KEY_DATE orExifInterface.TAG_DATETIME_ORIGINAL extracted from this media item.
String DISC_NUMBER Indexed value of MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER extracted from this media item.
String DISPLAY_NAME The display name of the media item.
String DOCUMENT_ID The "document ID" GUID as defined by the XMP Media Management standard, extracted from any XMP metadata contained within this media item.
String DURATION Indexed value of MediaMetadataRetriever.METADATA_KEY_DURATION extracted from this media item.
String GENERATION_ADDED Generation number at which metadata for this media item was first inserted.
String GENERATION_MODIFIED Generation number at which metadata for this media item was last changed.
String GENRE Indexed value of MediaMetadataRetriever.METADATA_KEY_GENRE extracted from this media item.
String HEIGHT Indexed value ofMediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT,MediaMetadataRetriever.METADATA_KEY_IMAGE_HEIGHT orExifInterface.TAG_IMAGE_LENGTH extracted from this media item.
String INFERRED_DATE File's approximate creation date.
String INSTANCE_ID The "instance ID" GUID as defined by the XMP Media Management standard, extracted from any XMP metadata contained within this media item.
String IS_DOWNLOAD Flag indicating if the media item has been marked as being part of the Downloads collection.
String IS_DRM Flag indicating if a media item is DRM protected.
String IS_FAVORITE Flag indicating if the media item has been marked as being a "favorite" by the user.
String IS_PENDING Flag indicating if a media item is pending, and still being inserted by its owner.
String IS_TRASHED Flag indicating if a media item is trashed.
String MIME_TYPE The MIME type of the media item.
String NUM_TRACKS Indexed value of MediaMetadataRetriever.METADATA_KEY_NUM_TRACKS extracted from this media item.
String OEM_METADATA Column which allows OEMs to store custom metadata for a media file.
String ORIENTATION Indexed value ofMediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION,MediaMetadataRetriever.METADATA_KEY_IMAGE_ROTATION, orExifInterface.TAG_ORIENTATION extracted from this media item.
String ORIGINAL_DOCUMENT_ID The "original document ID" GUID as defined by the XMP Media Management standard, extracted from any XMP metadata contained within this media item.
String OWNER_PACKAGE_NAME Package name that contributed this media.
String RELATIVE_PATH Relative path of this media item within the storage device where it is persisted.
String RESOLUTION Calculated value that combines WIDTH and HEIGHT into a user-presentable string.
String SIZE Indexed value of File.length() extracted from this media item.
String TITLE Indexed value of MediaMetadataRetriever.METADATA_KEY_TITLE extracted from this media item.
String VOLUME_NAME Volume name of the specific storage device where this media item is persisted.
String WIDTH Indexed value ofMediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH,MediaMetadataRetriever.METADATA_KEY_IMAGE_WIDTH orExifInterface.TAG_IMAGE_WIDTH extracted from this media item.
String WRITER Indexed value of MediaMetadataRetriever.METADATA_KEY_WRITER extracted from this media item.
String XMP Indexed XMP metadata extracted from this media item.
String YEAR Indexed value of MediaMetadataRetriever.METADATA_KEY_YEAR extracted from this media item.
Inherited constants
From interfaceandroid.provider.BaseColumns String _COUNT The count of rows in a directory. String _ID The unique ID for a row.

Constants

BUCKET_DISPLAY_NAME

public static final String BUCKET_DISPLAY_NAME

The primary bucket display name of this media item. This can be useful to present the user a first-level clustering of related media items. This is a read-only column that is automatically computed.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) , and are read-only and cannot be mutated.

Constant Value: "bucket_display_name"

BUCKET_ID

public static final String BUCKET_ID

The primary bucket ID of this media item. This can be useful to present the user a first-level clustering of related media items. This is a read-only column that is automatically computed.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) , and are read-only and cannot be mutated.

Constant Value: "bucket_id"

DATA

public static final String DATA

Absolute filesystem path to the media item on disk.

Apps may use this path to do file operations. However, they should not assume that the file is always available. Apps must be prepared to handle any file-based I/O errors that could occur.

From Android 11 onwards, this column is read-only for apps that target[R](/reference/android/os/Build.VERSION%5FCODES#R) and higher. On those devices, when creating or updating a uri, this column's value is not accepted. Instead, to update the filesystem location of a file, use the values of the [DISPLAY_NAME](/reference/android/provider/MediaStore.MediaColumns#DISPLAY%5FNAME) and[RELATIVE_PATH](/reference/android/provider/MediaStore.MediaColumns#RELATIVE%5FPATH) columns.

Though direct file operations are supported,[ContentResolver.openFileDescriptor(Uri,String)](/reference/android/content/ContentResolver#openFileDescriptor%28android.net.Uri,%20java.lang.String%29) API is recommended for better performance.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) .

Constant Value: "_data"

DATE_ADDED

public static final String DATE_ADDED

The time the media item was first added.
Value is a non-negative timestamp measured as the number of seconds since 1970-01-01T00:00:00Z.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) , and are read-only and cannot be mutated.

Constant Value: "date_added"

DATE_EXPIRES

public static final String DATE_EXPIRES

The time the media item should be considered expired. Typically only meaningful in the context of [IS_PENDING](/reference/android/provider/MediaStore.MediaColumns#IS%5FPENDING) or[IS_TRASHED](/reference/android/provider/MediaStore.MediaColumns#IS%5FTRASHED).

The value stored in this column is automatically calculated when[IS_PENDING](/reference/android/provider/MediaStore.MediaColumns#IS%5FPENDING) or [IS_TRASHED](/reference/android/provider/MediaStore.MediaColumns#IS%5FTRASHED) is changed. The default pending expiration is typically 7 days, and the default trashed expiration is typically 30 days.

Expired media items are automatically deleted once their expiration time has passed, typically during the next device idle period.
Value is a non-negative timestamp measured as the number of seconds since 1970-01-01T00:00:00Z.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) , and are read-only and cannot be mutated.

Constant Value: "date_expires"

DATE_MODIFIED

public static final String DATE_MODIFIED

Indexed value of [File.lastModified()](/reference/java/io/File#lastModified%28%29) extracted from this media item.
Value is a non-negative timestamp measured as the number of seconds since 1970-01-01T00:00:00Z.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) , and are read-only and cannot be mutated.

Constant Value: "date_modified"

DISPLAY_NAME

public static final String DISPLAY_NAME

The display name of the media item.

For example, an item stored at/storage/0000-0000/DCIM/Vacation/IMG1024.JPG would have a display name of IMG1024.JPG.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) .

Constant Value: "_display_name"

DOCUMENT_ID

public static final String DOCUMENT_ID

The "document ID" GUID as defined by the XMP Media Management standard, extracted from any XMP metadata contained within this media item. The value is null when no metadata was found.

Each "document ID" is created once for each new resource. Different renditions of that resource are expected to have different IDs.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) , and are read-only and cannot be mutated.

Constant Value: "document_id"

GENERATION_ADDED

public static final String GENERATION_ADDED

Generation number at which metadata for this media item was first inserted. This is useful for apps that are attempting to quickly identify exactly which media items have been added since a previous point in time. Generation numbers are monotonically increasing over time, and can be safely arithmetically compared.

Detecting media additions using generation numbers is more robust than using [DATE_ADDED](/reference/android/provider/MediaStore.MediaColumns#DATE%5FADDED), since those values may change in unexpected ways when apps use [File.setLastModified(long)](/reference/java/io/File#setLastModified%28long%29) or when the system clock is set incorrectly.

Note that before comparing these detailed generation values, you should first confirm that the overall version hasn't changed by checking [MediaStore.getVersion(Context,String)](/reference/android/provider/MediaStore#getVersion%28android.content.Context,%20java.lang.String%29), since that indicates when a more radical change has occurred. If the overall version changes, you should assume that generation numbers have been reset and perform a full synchronization pass.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) , and are read-only and cannot be mutated.

Constant Value: "generation_added"

GENERATION_MODIFIED

public static final String GENERATION_MODIFIED

Generation number at which metadata for this media item was last changed. This is useful for apps that are attempting to quickly identify exactly which media items have changed since a previous point in time. Generation numbers are monotonically increasing over time, and can be safely arithmetically compared.

Detecting media changes using generation numbers is more robust than using [DATE_MODIFIED](/reference/android/provider/MediaStore.MediaColumns#DATE%5FMODIFIED), since those values may change in unexpected ways when apps use [File.setLastModified(long)](/reference/java/io/File#setLastModified%28long%29) or when the system clock is set incorrectly.

Note that before comparing these detailed generation values, you should first confirm that the overall version hasn't changed by checking [MediaStore.getVersion(Context,String)](/reference/android/provider/MediaStore#getVersion%28android.content.Context,%20java.lang.String%29), since that indicates when a more radical change has occurred. If the overall version changes, you should assume that generation numbers have been reset and perform a full synchronization pass.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) , and are read-only and cannot be mutated.

Constant Value: "generation_modified"

INSTANCE_ID

public static final String INSTANCE_ID

The "instance ID" GUID as defined by the XMP Media Management standard, extracted from any XMP metadata contained within this media item. The value is null when no metadata was found.

This "instance ID" changes with each save operation of a specific "document ID".
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) , and are read-only and cannot be mutated.

Constant Value: "instance_id"

IS_DOWNLOAD

public static final String IS_DOWNLOAD

Flag indicating if the media item has been marked as being part of the [Downloads](/reference/android/provider/MediaStore.Downloads) collection.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) , and are read-only and cannot be mutated.

Constant Value: "is_download"

IS_PENDING

public static final String IS_PENDING

Flag indicating if a media item is pending, and still being inserted by its owner. While this flag is set, only the owner of the item can open the underlying file; requests from other apps will be rejected.

Pending items are retained either until they are published by setting the field to 0, or until they expire as defined by[DATE_EXPIRES](/reference/android/provider/MediaStore.MediaColumns#DATE%5FEXPIRES).
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) .

Constant Value: "is_pending"

MIME_TYPE

public static final String MIME_TYPE

The MIME type of the media item.

This is typically defined based on the file extension of the media item. However, it may be the value of the format attribute defined by the Dublin Core Media Initiative standard, extracted from any XMP metadata contained within this media item.

Note: the format attribute may be ignored if the top-level MIME type disagrees with the file extension. For example, it's reasonable for an image/jpeg file to declare a format of image/vnd.google.panorama360+jpg, but declaring aformat of audio/ogg would be ignored.

This is a read-only column that is automatically computed.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) .

Constant Value: "mime_type"

OEM_METADATA

public static final String OEM_METADATA

Column which allows OEMs to store custom metadata for a media file.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_BLOB](/reference/android/database/Cursor#FIELD%5FTYPE%5FBLOB) , and are read-only and cannot be mutated.

Constant Value: "oem_metadata"

ORIGINAL_DOCUMENT_ID

public static final String ORIGINAL_DOCUMENT_ID

The "original document ID" GUID as defined by the XMP Media Management standard, extracted from any XMP metadata contained within this media item.

This "original document ID" links a resource to its original source. For example, when you save a PSD document as a JPEG, then convert the JPEG to GIF format, the "original document ID" of both the JPEG and GIF files is the "document ID" of the original PSD file.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) , and are read-only and cannot be mutated.

Constant Value: "original_document_id"

RELATIVE_PATH

public static final String RELATIVE_PATH

Relative path of this media item within the storage device where it is persisted. For example, an item stored at/storage/0000-0000/DCIM/Vacation/IMG1024.JPG would have a path of DCIM/Vacation/.

This value should only be used for organizational purposes, and you should not attempt to construct or access a raw filesystem path using this value. If you need to open a media item, use an API like[ContentResolver.openFileDescriptor(Uri,String)](/reference/android/content/ContentResolver#openFileDescriptor%28android.net.Uri,%20java.lang.String%29).

When this value is set to NULL during an[ContentResolver.insert](/reference/android/content/ContentResolver#insert%28android.net.Uri,%20android.content.ContentValues%29) operation, the newly created item will be placed in a relevant default location based on the type of media being inserted. For example, a image/jpeg item will be placed under [Environment.DIRECTORY_PICTURES](/reference/android/os/Environment#DIRECTORY%5FPICTURES).

You can modify this column during an [ContentResolver.update](/reference/android/content/ContentResolver#update%28android.net.Uri,%20android.content.ContentValues,%20android.os.Bundle%29) call, which will move the underlying file on disk.

In both cases above, content must be placed under a top-level directory that is relevant to the media type. For example, attempting to place a audio/mpeg file under[Environment.DIRECTORY_PICTURES](/reference/android/os/Environment#DIRECTORY%5FPICTURES) will be rejected.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) .

Constant Value: "relative_path"

RESOLUTION

public static final String RESOLUTION

Calculated value that combines [WIDTH](/reference/android/provider/MediaStore.MediaColumns#WIDTH) and [HEIGHT](/reference/android/provider/MediaStore.MediaColumns#HEIGHT) into a user-presentable string.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) , and are read-only and cannot be mutated.

Constant Value: "resolution"

SIZE

public static final String SIZE

Indexed value of [File.length()](/reference/java/io/File#length%28%29) extracted from this media item.
Value is a non-negative number of bytes.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_INTEGER](/reference/android/database/Cursor#FIELD%5FTYPE%5FINTEGER) , and are read-only and cannot be mutated.

Constant Value: "_size"

VOLUME_NAME

public static final String VOLUME_NAME

Volume name of the specific storage device where this media item is persisted. The value is typically one of the volume names returned from [MediaStore.getExternalVolumeNames(Context)](/reference/android/provider/MediaStore#getExternalVolumeNames%28android.content.Context%29).

This is a read-only column that is automatically computed.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_STRING](/reference/android/database/Cursor#FIELD%5FTYPE%5FSTRING) , and are read-only and cannot be mutated.

Constant Value: "volume_name"

XMP

public static final String XMP

Indexed XMP metadata extracted from this media item.

The structure of this metadata is defined by the XMP Media Management standard, published as ISO 16684-1:2012.

This metadata is typically extracted from a[ExifInterface.TAG_XMP](/reference/android/media/ExifInterface#TAG%5FXMP) contained inside an image file or from a XMP_ box contained inside an ISO/IEC base media file format (MPEG-4 Part 12).

Note that any location details are redacted from this metadata for privacy reasons.
This constant represents a column name that can be used with a [ContentProvider](/reference/android/content/ContentProvider) through a [ContentValues](/reference/android/content/ContentValues) or [Cursor](/reference/android/database/Cursor) object. The values stored in this column are [Cursor#FIELD_TYPE_BLOB](/reference/android/database/Cursor#FIELD%5FTYPE%5FBLOB) , and are read-only and cannot be mutated.

Constant Value: "xmp"