MediaStore.Images.Media


public static final class MediaStore.Images.Media
extends Object implements MediaStore.Images.ImageColumns

java.lang.Object
   ↳ android.provider.MediaStore.Images.Media


Summary

Constants

String CONTENT_TYPE

The MIME type of this directory of images.

String DEFAULT_SORT_ORDER

The default sort order for this table

Inherited constants

String DESCRIPTION

Indexed value of ExifInterface.TAG_IMAGE_DESCRIPTION extracted from this media item.

String EXPOSURE_TIME

Indexed value of ExifInterface.TAG_EXPOSURE_TIME extracted from this media item.

String F_NUMBER

Indexed value of ExifInterface.TAG_F_NUMBER extracted from this media item.

String ISO

Indexed value of ExifInterface.TAG_ISO_SPEED_RATINGS extracted from this media item.

String IS_PRIVATE

Whether the image should be published as public or private
This constant represents a column name that can be used with a ContentProvider through a ContentValues or Cursor object.

String LATITUDE

This constant was deprecated in API level 29. location details are no longer indexed for privacy reasons, and this value is now always null. You can still manually obtain location metadata using ExifInterface.getLatLong(float[]).

String LONGITUDE

This constant was deprecated in API level 29. location details are no longer indexed for privacy reasons, and this value is now always null. You can still manually obtain location metadata using ExifInterface.getLatLong(float[]).

String MINI_THUMB_MAGIC

This constant was deprecated in API level 29. all thumbnails should be obtained via MediaStore.Images.Thumbnails.getThumbnail, as this value is no longer supported.

String PICASA_ID

This constant was deprecated in API level 29. this value was only relevant for images hosted on Picasa, which are no longer supported.

String SCENE_CAPTURE_TYPE

Indexed value of ExifInterface.TAG_SCENE_CAPTURE_TYPE extracted from this media item.

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 of MediaMetadataRetriever.METADATA_KEY_CAPTURE_FRAMERATE extracted from this media item.

String CD_TRACK_NUMBER

Indexed value of MediaMetadataRetriever.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 or ExifInterface.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 of MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT, MediaMetadataRetriever.METADATA_KEY_IMAGE_HEIGHT or ExifInterface.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 of MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION, MediaMetadataRetriever.METADATA_KEY_IMAGE_ROTATION, or ExifInterface.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 of MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH, MediaMetadataRetriever.METADATA_KEY_IMAGE_WIDTH or ExifInterface.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.

String _COUNT

The count of rows in a directory.

String _ID

The unique ID for a row.

Fields

public static final Uri EXTERNAL_CONTENT_URI

The content:// style URI for the "primary" external storage volume.

public static final Uri INTERNAL_CONTENT_URI

The content:// style URI for the internal storage.

Public constructors

Media()

Public methods

static Bitmap getBitmap(ContentResolver cr, Uri url)

This method was deprecated in API level 29. loading of images should be performed through ImageDecoder.createSource(ContentResolver, Uri), which offers modern features like PostProcessor.

static Uri getContentUri(String volumeName)

Get the content:// style URI for the image media table on the given volume.

static Uri getContentUri(String volumeName, long id)

Get the content:// style URI for a single row in the images table on the given volume.

static String insertImage(ContentResolver cr, Bitmap source, String title, String description)

This method was deprecated in API level 29. inserting of images should be performed using MediaColumns.IS_PENDING, which offers richer control over lifecycle.

static String insertImage(ContentResolver cr, String imagePath, String name, String description)

This method was deprecated in API level 29. inserting of images should be performed using MediaColumns.IS_PENDING, which offers richer control over lifecycle.

static Cursor query(ContentResolver cr, Uri uri, String[] projection)

This method was deprecated in API level 29. all queries should be performed through ContentResolver directly, which offers modern features like CancellationSignal.

static Cursor query(ContentResolver cr, Uri uri, String[] projection, String where, String orderBy)

This method was deprecated in API level 29. all queries should be performed through ContentResolver directly, which offers modern features like CancellationSignal.

static Cursor query(ContentResolver cr, Uri uri, String[] projection, String selection, String[] selectionArgs, String orderBy)

This method was deprecated in API level 29. all queries should be performed through ContentResolver directly, which offers modern features like CancellationSignal.

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Constants

CONTENT_TYPE

Added in API level 1
public static final String CONTENT_TYPE

The MIME type of this directory of images. Note that each entry in this directory will have a standard image MIME type as appropriate -- for example, image/jpeg.

Constant Value: "vnd.android.cursor.dir/image"

DEFAULT_SORT_ORDER

Added in API level 1
public static final String DEFAULT_SORT_ORDER

The default sort order for this table

Constant Value: "bucket_display_name"

Fields

EXTERNAL_CONTENT_URI

Added in API level 1
public static final Uri EXTERNAL_CONTENT_URI

The content:// style URI for the "primary" external storage volume.

INTERNAL_CONTENT_URI

Added in API level 1
public static final Uri INTERNAL_CONTENT_URI

The content:// style URI for the internal storage.

Public constructors

Media

Added in API level 1
public Media ()

Public methods

getBitmap

Added in API level 1
Deprecated in API level 29
public static Bitmap getBitmap (ContentResolver cr, 
                Uri url)

This method was deprecated in API level 29.
loading of images should be performed through ImageDecoder.createSource(ContentResolver, Uri), which offers modern features like PostProcessor.

Retrieves an image for the given url as a Bitmap.

Parameters
cr ContentResolver: The content resolver to use

url Uri: The url of the image

Returns
Bitmap

getContentUri

Added in API level 1
public static Uri getContentUri (String volumeName)

Get the content:// style URI for the image media table on the given volume.

Parameters
volumeName String: the name of the volume to get the URI for

Returns
Uri the URI to the image media table on the given volume

getContentUri

Added in API level 30
public static Uri getContentUri (String volumeName, 
                long id)

Get the content:// style URI for a single row in the images table on the given volume.

Parameters
volumeName String: the name of the volume to get the URI for This value cannot be null.

id long: the image to get the URI for

Returns
Uri the URI to the images table on the given volume This value cannot be null.

insertImage

Added in API level 1
Deprecated in API level 29
public static String insertImage (ContentResolver cr, 
                Bitmap source, 
                String title, 
                String description)

This method was deprecated in API level 29.
inserting of images should be performed using MediaColumns.IS_PENDING, which offers richer control over lifecycle.

Insert an image and create a thumbnail for it.

Parameters
cr ContentResolver: The content resolver to use

source Bitmap: The stream to use for the image

title String: The name of the image

description String: The description of the image

Returns
String The URL to the newly created image, or null if the image failed to be stored for any reason.

insertImage

Added in API level 1
Deprecated in API level 29
public static String insertImage (ContentResolver cr, 
                String imagePath, 
                String name, 
                String description)

This method was deprecated in API level 29.
inserting of images should be performed using MediaColumns.IS_PENDING, which offers richer control over lifecycle.

Insert an image and create a thumbnail for it.

Parameters
cr ContentResolver: The content resolver to use

imagePath String: The path to the image to insert

name String: The name of the image

description String: The description of the image

Returns
String The URL to the newly created image

query

Added in API level 1
Deprecated in API level 29
public static Cursor query (ContentResolver cr, 
                Uri uri, 
                String[] projection)

This method was deprecated in API level 29.
all queries should be performed through ContentResolver directly, which offers modern features like CancellationSignal.

Parameters
cr ContentResolver

uri Uri

projection String

Returns
Cursor

query

Added in API level 1
Deprecated in API level 29
public static Cursor query (ContentResolver cr, 
                Uri uri, 
                String[] projection, 
                String where, 
                String orderBy)

This method was deprecated in API level 29.
all queries should be performed through ContentResolver directly, which offers modern features like CancellationSignal.

Parameters
cr ContentResolver

uri Uri

projection String

where String

orderBy String

Returns
Cursor

query

Added in API level 1
Deprecated in API level 29
public static Cursor query (ContentResolver cr, 
                Uri uri, 
                String[] projection, 
                String selection, 
                String[] selectionArgs, 
                String orderBy)

This method was deprecated in API level 29.
all queries should be performed through ContentResolver directly, which offers modern features like CancellationSignal.

Parameters
cr ContentResolver

uri Uri

projection String

selection String

selectionArgs String

orderBy String

Returns
Cursor