Most visited

Recently visited

Added in API level 1

MediaStore

public final class MediaStore
extends Object

java.lang.Object
   ↳ android.provider.MediaStore


The Media provider contains meta data for all available media on both internal and external storage devices.

Summary

Nested classes

class MediaStore.Audio

Container for all audio content. 

class MediaStore.Files

Media provider table containing an index of all files in the media storage, including non-media files. 

class MediaStore.Images

Contains meta data for all available images. 

interface MediaStore.MediaColumns

Common fields for most MediaProvider tables  

class MediaStore.Video

 

Constants

String ACTION_IMAGE_CAPTURE

Standard Intent action that can be sent to have the camera application capture an image and return it.

String ACTION_IMAGE_CAPTURE_SECURE

Intent action that can be sent to have the camera application capture an image and return it when the device is secured (e.g.

String ACTION_VIDEO_CAPTURE

Standard Intent action that can be sent to have the camera application capture a video and return it.

String AUTHORITY

String EXTRA_DURATION_LIMIT

Specify the maximum allowed recording duration in seconds.

String EXTRA_FINISH_ON_COMPLETION

The name of the Intent-extra used to control the onCompletion behavior of a MovieView.

String EXTRA_FULL_SCREEN

The name of an Intent-extra used to control the UI of a ViewImage.

String EXTRA_MEDIA_ALBUM

The name of the Intent-extra used to define the album

String EXTRA_MEDIA_ARTIST

The name of the Intent-extra used to define the artist

String EXTRA_MEDIA_FOCUS

The name of the Intent-extra used to define the search focus.

String EXTRA_MEDIA_GENRE

The name of the Intent-extra used to define the genre.

String EXTRA_MEDIA_PLAYLIST

The name of the Intent-extra used to define the playlist.

String EXTRA_MEDIA_RADIO_CHANNEL

The name of the Intent-extra used to define the radio channel.

String EXTRA_MEDIA_TITLE

The name of the Intent-extra used to define the song title

String EXTRA_OUTPUT

The name of the Intent-extra used to indicate a content resolver Uri to be used to store the requested image or video.

String EXTRA_SCREEN_ORIENTATION

The name of the Intent-extra used to control the orientation of a ViewImage or a MovieView.

String EXTRA_SHOW_ACTION_ICONS

The name of an Intent-extra used to control the UI of a ViewImage.

String EXTRA_SIZE_LIMIT

Specify the maximum allowed size.

String EXTRA_VIDEO_QUALITY

The name of the Intent-extra used to control the quality of a recorded video.

String INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH

An intent to perform a search for music media and automatically play content from the result when possible.

String INTENT_ACTION_MEDIA_SEARCH

Activity Action: Perform a search for media.

String INTENT_ACTION_MUSIC_PLAYER

This constant was deprecated in API level 15. Use CATEGORY_APP_MUSIC instead.

String INTENT_ACTION_STILL_IMAGE_CAMERA

The name of the Intent action used to launch a camera in still image mode.

String INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE

The name of the Intent action used to launch a camera in still image mode for use when the device is secured (e.g.

String INTENT_ACTION_TEXT_OPEN_FROM_SEARCH

An intent to perform a search for readable media and automatically play content from the result when possible.

String INTENT_ACTION_VIDEO_CAMERA

The name of the Intent action used to launch a camera in video mode.

String INTENT_ACTION_VIDEO_PLAY_FROM_SEARCH

An intent to perform a search for video media and automatically play content from the result when possible.

String MEDIA_IGNORE_FILENAME

Name of the file signaling the media scanner to ignore media in the containing directory and its subdirectories.

String MEDIA_SCANNER_VOLUME

Name of current volume being scanned by the media scanner.

String META_DATA_STILL_IMAGE_CAMERA_PREWARM_SERVICE

Name under which an activity handling INTENT_ACTION_STILL_IMAGE_CAMERA or INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE publishes the service name for its prewarm service.

String UNKNOWN_STRING

The string that is used when a media attribute is not known.

Public constructors

MediaStore()

Public methods

static Uri getMediaScannerUri()

Uri for querying the state of the media scanner.

static String getVersion(Context context)

Get the media provider's version.

Inherited methods

From class java.lang.Object

Constants

ACTION_IMAGE_CAPTURE

Added in API level 3
String ACTION_IMAGE_CAPTURE

Standard Intent action that can be sent to have the camera application capture an image and return it.

The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT. As of LOLLIPOP, this uri can also be supplied through setClipData(ClipData). If using this approach, you still must supply the uri through the EXTRA_OUTPUT field for compatibility with old applications. If you don't set a ClipData, it will be copied there for you when calling startActivity(Intent).

Note: if you app targets M and above and declares as using the CAMERA permission which is not granted, then attempting to use this action will result in a SecurityException.

See also:

Constant Value: "android.media.action.IMAGE_CAPTURE"

ACTION_IMAGE_CAPTURE_SECURE

Added in API level 17
String ACTION_IMAGE_CAPTURE_SECURE

Intent action that can be sent to have the camera application capture an image and return it when the device is secured (e.g. with a pin, password, pattern, or face unlock). Applications responding to this intent must not expose any personal content like existing photos or videos on the device. The applications should be careful not to share any photo or video with other applications or internet. The activity should use FLAG_SHOW_WHEN_LOCKED to display on top of the lock screen while secured. There is no activity stack when this flag is used, so launching more than one activity is strongly discouraged.

The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT. As of LOLLIPOP, this uri can also be supplied through setClipData(ClipData). If using this approach, you still must supply the uri through the EXTRA_OUTPUT field for compatibility with old applications. If you don't set a ClipData, it will be copied there for you when calling startActivity(Intent).

See also:

Constant Value: "android.media.action.IMAGE_CAPTURE_SECURE"

ACTION_VIDEO_CAPTURE

Added in API level 3
String ACTION_VIDEO_CAPTURE

Standard Intent action that can be sent to have the camera application capture a video and return it.

The caller may pass in an extra EXTRA_VIDEO_QUALITY to control the video quality.

The caller may pass in an extra EXTRA_OUTPUT to control where the video is written. If EXTRA_OUTPUT is not present the video will be written to the standard location for videos, and the Uri of that location will be returned in the data field of the Uri. As of LOLLIPOP, this uri can also be supplied through setClipData(ClipData). If using this approach, you still must supply the uri through the EXTRA_OUTPUT field for compatibility with old applications. If you don't set a ClipData, it will be copied there for you when calling startActivity(Intent).

Note: if you app targets M and above and declares as using the CAMERA permission which is not granted, then atempting to use this action will result in a SecurityException.

See also:

Constant Value: "android.media.action.VIDEO_CAPTURE"

AUTHORITY

Added in API level 1
String AUTHORITY

Constant Value: "media"

EXTRA_DURATION_LIMIT

Added in API level 8
String EXTRA_DURATION_LIMIT

Specify the maximum allowed recording duration in seconds.

Constant Value: "android.intent.extra.durationLimit"

EXTRA_FINISH_ON_COMPLETION

Added in API level 3
String EXTRA_FINISH_ON_COMPLETION

The name of the Intent-extra used to control the onCompletion behavior of a MovieView. This is a boolean property that specifies whether or not to finish the MovieView activity when the movie completes playing. The default value is true, which means to automatically exit the movie player activity when the movie completes playing.

Constant Value: "android.intent.extra.finishOnCompletion"

EXTRA_FULL_SCREEN

Added in API level 8
String EXTRA_FULL_SCREEN

The name of an Intent-extra used to control the UI of a ViewImage. This is a boolean property that overrides the activity's default fullscreen state.

Constant Value: "android.intent.extra.fullScreen"

EXTRA_MEDIA_ALBUM

Added in API level 3
String EXTRA_MEDIA_ALBUM

The name of the Intent-extra used to define the album

Constant Value: "android.intent.extra.album"

EXTRA_MEDIA_ARTIST

Added in API level 3
String EXTRA_MEDIA_ARTIST

The name of the Intent-extra used to define the artist

Constant Value: "android.intent.extra.artist"

EXTRA_MEDIA_FOCUS

Added in API level 3
String EXTRA_MEDIA_FOCUS

The name of the Intent-extra used to define the search focus. The search focus indicates whether the search should be for things related to the artist, album or song that is identified by the other extras.

Constant Value: "android.intent.extra.focus"

EXTRA_MEDIA_GENRE

Added in API level 21
String EXTRA_MEDIA_GENRE

The name of the Intent-extra used to define the genre.

Constant Value: "android.intent.extra.genre"

EXTRA_MEDIA_PLAYLIST

Added in API level 21
String EXTRA_MEDIA_PLAYLIST

The name of the Intent-extra used to define the playlist.

Constant Value: "android.intent.extra.playlist"

EXTRA_MEDIA_RADIO_CHANNEL

Added in API level 21
String EXTRA_MEDIA_RADIO_CHANNEL

The name of the Intent-extra used to define the radio channel.

Constant Value: "android.intent.extra.radio_channel"

EXTRA_MEDIA_TITLE

Added in API level 3
String EXTRA_MEDIA_TITLE

The name of the Intent-extra used to define the song title

Constant Value: "android.intent.extra.title"

EXTRA_OUTPUT

Added in API level 3
String EXTRA_OUTPUT

The name of the Intent-extra used to indicate a content resolver Uri to be used to store the requested image or video.

Constant Value: "output"

EXTRA_SCREEN_ORIENTATION

Added in API level 3
String EXTRA_SCREEN_ORIENTATION

The name of the Intent-extra used to control the orientation of a ViewImage or a MovieView. This is an int property that overrides the activity's requestedOrientation.

See also:

Constant Value: "android.intent.extra.screenOrientation"

EXTRA_SHOW_ACTION_ICONS

Added in API level 8
String EXTRA_SHOW_ACTION_ICONS

The name of an Intent-extra used to control the UI of a ViewImage. This is a boolean property that specifies whether or not to show action icons.

Constant Value: "android.intent.extra.showActionIcons"

EXTRA_SIZE_LIMIT

Added in API level 8
String EXTRA_SIZE_LIMIT

Specify the maximum allowed size.

Constant Value: "android.intent.extra.sizeLimit"

EXTRA_VIDEO_QUALITY

Added in API level 3
String EXTRA_VIDEO_QUALITY

The name of the Intent-extra used to control the quality of a recorded video. This is an integer property. Currently value 0 means low quality, suitable for MMS messages, and value 1 means high quality. In the future other quality levels may be added.

Constant Value: "android.intent.extra.videoQuality"

INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH

Added in API level 9
String INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH

An intent to perform a search for music media and automatically play content from the result when possible. This can be fired, for example, by the result of a voice recognition command to listen to music.

This intent always includes the EXTRA_MEDIA_FOCUS and QUERY extras. The EXTRA_MEDIA_FOCUS extra determines the search mode, and the value of the QUERY extra depends on the search mode. For more information about the search modes for this intent, see Play music based on a search query in Common Intents.

This intent makes the most sense for apps that can support large-scale search of music, such as services connected to an online database of music which can be streamed and played on the device.

Constant Value: "android.media.action.MEDIA_PLAY_FROM_SEARCH"

INTENT_ACTION_MEDIA_SEARCH

Added in API level 3
String INTENT_ACTION_MEDIA_SEARCH

Activity Action: Perform a search for media. Contains at least the QUERY extra. May also contain any combination of the following extras: EXTRA_MEDIA_ARTIST, EXTRA_MEDIA_ALBUM, EXTRA_MEDIA_TITLE, EXTRA_MEDIA_FOCUS

See also:

Constant Value: "android.intent.action.MEDIA_SEARCH"

INTENT_ACTION_MUSIC_PLAYER

Added in API level 8
String INTENT_ACTION_MUSIC_PLAYER

This constant was deprecated in API level 15.
Use CATEGORY_APP_MUSIC instead.

Activity Action: Launch a music player. The activity should be able to play, browse, or manipulate music files stored on the device.

Constant Value: "android.intent.action.MUSIC_PLAYER"

INTENT_ACTION_STILL_IMAGE_CAMERA

Added in API level 3
String INTENT_ACTION_STILL_IMAGE_CAMERA

The name of the Intent action used to launch a camera in still image mode.

Constant Value: "android.media.action.STILL_IMAGE_CAMERA"

INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE

Added in API level 17
String INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE

The name of the Intent action used to launch a camera in still image mode for use when the device is secured (e.g. with a pin, password, pattern, or face unlock). Applications responding to this intent must not expose any personal content like existing photos or videos on the device. The applications should be careful not to share any photo or video with other applications or internet. The activity should use FLAG_SHOW_WHEN_LOCKED to display on top of the lock screen while secured. There is no activity stack when this flag is used, so launching more than one activity is strongly discouraged.

Constant Value: "android.media.action.STILL_IMAGE_CAMERA_SECURE"

INTENT_ACTION_TEXT_OPEN_FROM_SEARCH

Added in API level 17
String INTENT_ACTION_TEXT_OPEN_FROM_SEARCH

An intent to perform a search for readable media and automatically play content from the result when possible. This can be fired, for example, by the result of a voice recognition command to read a book or magazine.

Contains the QUERY extra, which is a string that can contain any type of unstructured text search, like the name of a book or magazine, an author a genre, a publisher, or any combination of these.

Because this intent includes an open-ended unstructured search string, it makes the most sense for apps that can support large-scale search of text media, such as services connected to an online database of books and/or magazines which can be read on the device.

Constant Value: "android.media.action.TEXT_OPEN_FROM_SEARCH"

INTENT_ACTION_VIDEO_CAMERA

Added in API level 3
String INTENT_ACTION_VIDEO_CAMERA

The name of the Intent action used to launch a camera in video mode.

Constant Value: "android.media.action.VIDEO_CAMERA"

INTENT_ACTION_VIDEO_PLAY_FROM_SEARCH

Added in API level 17
String INTENT_ACTION_VIDEO_PLAY_FROM_SEARCH

An intent to perform a search for video media and automatically play content from the result when possible. This can be fired, for example, by the result of a voice recognition command to play movies.

Contains the QUERY extra, which is a string that can contain any type of unstructured video search, like the name of a movie, one or more actors, a genre, or any combination of these.

Because this intent includes an open-ended unstructured search string, it makes the most sense for apps that can support large-scale search of video, such as services connected to an online database of videos which can be streamed and played on the device.

Constant Value: "android.media.action.VIDEO_PLAY_FROM_SEARCH"

MEDIA_IGNORE_FILENAME

Added in API level 9
String MEDIA_IGNORE_FILENAME

Name of the file signaling the media scanner to ignore media in the containing directory and its subdirectories. Developers should use this to avoid application graphics showing up in the Gallery and likewise prevent application sounds and music from showing up in the Music app.

Constant Value: ".nomedia"

MEDIA_SCANNER_VOLUME

Added in API level 1
String MEDIA_SCANNER_VOLUME

Name of current volume being scanned by the media scanner.

Constant Value: "volume"

META_DATA_STILL_IMAGE_CAMERA_PREWARM_SERVICE

Added in API level 23
String META_DATA_STILL_IMAGE_CAMERA_PREWARM_SERVICE

Name under which an activity handling INTENT_ACTION_STILL_IMAGE_CAMERA or INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE publishes the service name for its prewarm service.

This meta-data should reference the fully qualified class name of the prewarm service extending CameraPrewarmService.

The prewarm service will get bound and receive a prewarm signal onPrewarm() when a camera launch intent fire might be imminent. An application implementing a prewarm service should do the absolute minimum amount of work to initialize the camera in order to reduce startup time in likely case that shortly after a camera launch intent would be sent.

Constant Value: "android.media.still_image_camera_preview_service"

UNKNOWN_STRING

Added in API level 8
String UNKNOWN_STRING

The string that is used when a media attribute is not known. For example, if an audio file does not have any meta data, the artist and album columns will be set to this value.

Constant Value: ""

Public constructors

MediaStore

Added in API level 1
MediaStore ()

Public methods

getMediaScannerUri

Added in API level 1
Uri getMediaScannerUri ()

Uri for querying the state of the media scanner.

Returns
Uri

getVersion

Added in API level 12
String getVersion (Context context)

Get the media provider's version. Applications that import data from the media provider into their own caches can use this to detect that the media provider changed, and reimport data as needed. No other assumptions should be made about the meaning of the version.

Parameters
context Context: Context to use for performing the query.
Returns
String A version string, or null if the version could not be determined.

Hooray!