MediaStore提供了對數據庫管理的對應信息,并且封裝了相關的方法方便上層調用。路徑如下:
/frameworks/base/core/java/android/provider/ MediaStore.java
(The Media provider contains meta data for all available media on both internal and external storage devices.)
1. 類結構圖
??下面對這些類進行分析并且總結一下方法和字段。
??首先,是MediaStore類的相關信息,包含在內部存儲和外部存儲的所有的多媒體文件元數據,提供相應方法和字段。
2. 字段
字段
解析
ACTION_IMAGE_CAPTURE
標準的intent action,發送給相機應用,拍攝照片并返回
ACTION_IMAGE_CAPTURE_SECURE
發送給相機應用,拍攝照片并返回,設備被固定
ACTION_VIDEO_CAPTURE
標準的intent action,發送給相機應用,錄制視頻并返回
AUTHORITY
"media"
EXTRA_DURATION_LIMIT
指定錄像時長的最大值
EXTRA_FINISH_ON_COMPLETION
Intent-extra的名字用來控制MovieView 的onCompletion方法
EXTRA_FULL_SCREEN
Intent-extra的名字用來控制ViewImage的UI
EXTRA_MEDIA_ALBUM
Intent-extra的名字用來定義album
EXTRA_MEDIA_ARTIST
Intent-extra的名字用來定義artist
EXTRA_MEDIA_FOCUS
Intent-extra的名字用來定義search focus.
EXTRA_MEDIA_TITLE
Intent-extra的名字用來定義 song title
EXTRA_OUTPUT
Intent-extra的名字用來表示一個存儲圖片和視頻content resolver 的Uri.
EXTRA_SCREEN_ORIENTATION
Intent-extra的名字用來控制ViewImage或者MovieView.
EXTRA_SHOW_ACTION_ICONS
Intent-extra的名字用來控制ViewImage的UI.
EXTRA_SIZE_LIMIT
指定最大字長.
EXTRA_VIDEO_QUALITY
Intent-extra的名字用來控制錄制視頻的質量.
INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH
一個顯示搜索音樂并且自動播放的Intent
INTENT_ACTION_MEDIA_SEARCH
Activity Action: 顯示搜索音樂.
INTENT_ACTION_MUSIC_PLAYER
This constant was deprecated in API level 15. Use CATEGORY_APP_MUSIC instead.
INTENT_ACTION_STILL_IMAGE_CAMERA
Intent action在圖片模式下啟動camera.
INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE
Intent action在圖片模式下啟動camera,設備被鎖定
INTENT_ACTION_TEXT_OPEN_FROM_SEARCH
顯示搜索可讀media文件并且自動播放的intent
INTENT_ACTION_VIDEO_CAMERA
Intent action 在錄像模式下啟動相機
INTENT_ACTION_VIDEO_PLAY_FROM_SEARCH
An intent to perform a search for video media and automatically play content from the result when possible.
MEDIA_IGNORE_FILENAME
Name of the file signaling the media scanner to ignore media in the containing directory and its subdirectories.
MEDIA_SCANNER_VOLUME
Name of current volume being scanned by the media scanner.
UNKNOWN_STRING
The string that is used when a media attribute is not known.
3. 方法
方法名
解析
getMediaScannerUri()
Uri for querying the state of the media scanner.
getVersion(Context context)
Get the media provider's version.
4. MediaStore內部類
根據上面的類結構圖可知,對于MediaStore內部類的屬性也非常重要,下面就其內部類相關信息進行總結。
4.1 Media.Audio
Media.Audio是所有音頻文件的容器。下面分析的是其內部類、字段和方法。
4.1.1 MediaStore.Audio.AlbumColumns
代表一張專輯的列。
字段
解析
ALBUM
The album on which the audio file appears, if any
ALBUM_ART
Cached album art.
ALBUM_ID
The id for the album
ALBUM_KEY
A non human readable key calculated from the ALBUM, used for searching, sorting and grouping
ARTIST
The artist whose songs appear on this album
FIRST_YEAR
The year in which the earliest songs on this album were released.
LAST_YEAR
The year in which the latest songs on this album were released.
NUMBER_OF_SONGS
The number of songs on this album
NUMBER_OF_SONGS_FOR_ARTIST
This column is available when getting album info via artist, and indicates the number of songs on the album by the given artist.
4.1.2 MediaStore.Audio.Albums
藝術家,繼承BaseColumns, AlbumColumns接口
字段
解析
CONTENT_TYPE
The MIME type for this table.
DEFAULT_SORT_ORDER
The default sort order for this table
ENTRY_CONTENT_TYPE
The MIME type for entries in this table.
方法
解析
getContentUri(String volumeName)
Get the content:// style URI for the albums table on the given volume.
4.1.3 MediaStore.Audio.ArtistColumns
代表一個藝術家的列
字段
解析
ARTIST
The artist who created the audio file, if any
ARTIST_KEY
A non human readable key calculated from the ARTIST, used for searching, sorting and grouping
NUMBER_OF_ALBUMS
The number of albums in the database for this artist
NUMBER_OF_TRACKS
The number of albums in the database for this artist
4.1.4 MediaStore.Audio.Artists
藝術家 ,繼承BaseColumns, ArtistColumns接口
內部類
解析
MediaStore.Audio.Artists.Albums
對于每個藝術家所包含的所有專輯的子目錄
字段
解析
CONTENT_TYPE
The MIME type for this table.
DEFAULT_SORT_ORDER
The default sort order for this table
ENTRY_CONTENT_TYPE
The MIME type for entries in this table.
EXTERNAL_CONTENT_URI
The content:// style URI for the "primary" external storage volume.
INTERNAL_CONTENT_URI
The content:// style URI for the internal storage.
方法
解析
getContentUri(String volumeName)
Get the content:// style URI for the artists table on the given volume.
4.1.5 MediaStore.Audio.AudioColumns
在多個表中展示出來的音頻文件的列
字段
解析
ALBUM
The album the audio file is from, if any
ALBUM_ID
The id of the album the audio file is from, if any
ALBUM_KEY
A non human readable key calculated from the ALBUM, used for searching, sorting and grouping
ARTIST
The artist who created the audio file, if any
ARTIST_ID
The id of the artist who created the audio file, if any
ARTIST_KEY
A non human readable key calculated from the ARTIST, used for searching, sorting and grouping
BOOKMARK
The position, in ms, playback was at when playback for this file was last stopped.
COMPOSER
The composer of the audio file, if any
DURATION
The duration of the audio file, in ms
IS_ALARM
Non-zero if the audio file may be an alarm
IS_MUSIC
Non-zero if the audio file is music
IS_NOTIFICATION
Non-zero if the audio file may be a notification sound
IS_PODCAST
Non-zero if the audio file is a podcast
IS_RINGTONE
Non-zero if the audio file may be a ringtone
TITLE_KEY
A non human readable key calculated from the TITLE, used for searching, sorting and grouping
TRACK
The track number of this song on the album, if any.
YEAR
The year the audio file was recorded, if any
4.1.6 MediaStore.Audio.Genres
包含音頻文件的流派,繼承BaseColumns, GenresColumns
內部類
解析
MediaStore.Audio.Genres.Members
對于每種流派所包含的所有成員的子目錄
字段
解析
CONTENT_TYPE
The MIME type for this table.
DEFAULT_SORT_ORDER
The default sort order for this table
ENTRY_CONTENT_TYPE
The MIME type for entries in this table.
EXTERNAL_CONTENT_URI
The content:// style URI for the "primary" external storage volume.
INTERNAL_CONTENT_URI
The content:// style URI for the internal storage.
方法
解析
getContentUri(String volumeName)
Get the content:// style URI for the audio genres table on the given volume.
getContentUriForAudioId(String volumeName, int audioId)
Get the content:// style URI for querying the genres of an audio file.
4.1.7 MediaStore.Audio.GenresColumns
代表一個音頻流派的列
字段
解析
NAME
The name of the genre
4.1.8 MediaStore.Audio.Media
繼承自AudioColumns
字段
解析
CONTENT_TYPE
The MIME type for this table.
DEFAULT_SORT_ORDER
The default sort order for this table
ENTRY_CONTENT_TYPE
The MIME type for an audio track.
EXTRA_MAX_BYTES
The name of the Intent-extra used to define a maximum file size for a recording made by the SoundRecorder application.
RECORD_SOUND_ACTION
Activity Action: Start SoundRecorder application.
EXTERNAL_CONTENT_URI
The content:// style URI for the "primary" external storage volume.
INTERNAL_CONTENT_URI
The content:// style URI for the internal storage.
方法
解析
getContentUri(String volumeName)
Get the content:// style URI for the audio media table on the given volume.
getContentUriForPath(String path)
4.1.9 MediaStore.Audio.Playlists
包含音頻文件的播放列表
內部類
解析
MediaStore.Audio.Playlists.Members
每個播放列表所包含的所有成員的子目錄
字段
解析
CONTENT_TYPE
The MIME type for this table.
DEFAULT_SORT_ORDER
The default sort order for this table
ENTRY_CONTENT_TYPE
The MIME type for entries in this table.
EXTERNAL_CONTENT_URI
The content:// style URI for the "primary" external storage volume.
INTERNAL_CONTENT_URI
The content:// style URI for the internal storage.
方法
解析
getContentUri(String volumeName)
Get the content:// style URI for the audio playlists table on the given volume.
4.1.10 MediaStore.Audio.PlaylistsColumns
代表播放列表的列
字段
解析
DATA
Path to the playlist file on disk.
DATE_ADDED
The time the file was added to the media provider Units are seconds since 1970.
DATE_MODIFIED
The time the file was last modified Units are seconds since 1970.
NAME
The name of the playlist
4.1.11 MediaStore.Audio.Radio
音頻文件中的收音機文件
字段
解析
ENTRY_CONTENT_TYPE
The MIME type for entries in this table.
4.2 Media.Files
Media provider的表,包含了多媒體存儲中所有文件的索引,包括非多媒體文件。這個類可以在單詞查詢中處理多媒體文件和非多媒體文件。
方法
解析
getContentUri(String volumeName)
Get the content:// style URI for the files table on the given volume.
getContentUri(String volumeName, long rowId)
Get the content:// style URI for a single row in the files table on the given volume.
4.2.1 MediaStore.Files.FileColumns
所有多媒體文件的主表字段
字段
解析
MEDIA_TYPE
The media type (audio, video, image or playlist) of the file, or 0 for not a media file
MEDIA_TYPE_AUDIO
Constant for the MEDIA_TYPE column indicating that file is an audio file.
MEDIA_TYPE_IMAGE
Constant for the MEDIA_TYPE column indicating that file is an image file.
MEDIA_TYPE_NONE
Constant for the MEDIA_TYPE column indicating that file is not an audio, image, video or playlist file.
MEDIA_TYPE_PLAYLIST
Constant for the MEDIA_TYPE column indicating that file is a playlist file.
MEDIA_TYPE_VIDEO
Constant for the MEDIA_TYPE column indicating that file is a video file.
MIME_TYPE
The MIME type of the file
PARENT
The index of the parent directory of the file
TITLE
The title of the content
4.3 MediaStore.Images
包含所有可用圖片的元數據。下面是對其內部類的整理:
4.3.1 MediaStore.Images.ImageColumns
代表所有圖片文件的列
字段
解析
BUCKET_DISPLAY_NAME
The bucket display name of the image.
BUCKET_ID
The bucket id of the image.
DATE_TAKEN
The date & time that the image was taken in units of milliseconds since jan 1, 1970.
DESCRIPTION
The description of the image
IS_PRIVATE
Whether the video should be published as public or private
LATITUDE
The latitude where the image was captured.
LONGITUDE
The longitude where the image was captured.
MINI_THUMB_MAGIC
The mini thumb id.
ORIENTATION
The orientation for the image expressed as degrees.
PICASA_ID
The picasa id of the image
4.3.2 MediaStore.Images.Media
提供各種操作方法,繼承ImageColumns
字段
解析
CONTENT_TYPE
The MIME type of of this directory of images.
DEFAULT_SORT_ORDER
The default sort order for this table
EXTERNAL_CONTENT_URI
The content:// style URI for the "primary" external storage volume.
INTERNAL_CONTENT_URI
The content:// style URI for the internal storage.
方法
解析
getBitmap(ContentResolver cr, Uri url)
Retrieves an image for the given url as a Bitmap.
getContentUri(String volumeName)
Get the content:// style URI for the image media table on the given volume.
insertImage(ContentResolver cr, String imagePath, String name, String description)
Insert an image and create a thumbnail for it.
insertImage(ContentResolver cr, Bitmap source, String title, String description)
Insert an image and create a thumbnail for it.
query(ContentResolver cr, Uri uri, String[] projection)
query(ContentResolver cr, Uri uri, String[] projection, String where,String orderBy)
query(ContentResolver cr, Uri uri, String[] projection, String selection,String[] selectionArgs, String orderBy)
4.3.3 MediaStore.Images.Thumbnails
這個類允許開發者去查詢并且得到兩種略縮圖,MINI_KIND: 512 x 384 thumbnail MICRO_KIND: 96 x 96 thumbnail
字段
解析
DATA
Path to the thumbnail file on disk.
DEFAULT_SORT_ORDER
The default sort order for this table
FULL_SCREEN_KIND
HEIGHT
The height of the thumbnail
IMAGE_ID
The original image for the thumbnal
KIND
The kind of the thumbnail
MICRO_KIND
MINI_KIND
THUMB_DATA
The blob raw data of thumbnail
WIDTH
The width of the thumbnal
EXTERNAL_CONTENT_URI
The content:// style URI for the "primary" external storage volume.
INTERNAL_CONTENT_URI
The content:// style URI for the internal storage.
方法
解析
cancelThumbnailRequest(ContentResolver cr, long origId)
This method cancels the thumbnail request so clients waiting for getThumbnail will be interrupted and return immediately.
cancelThumbnailRequest(ContentResolver cr, long origId, long groupId)
This method cancels the thumbnail request so clients waiting for getThumbnail will be interrupted and return immediately.
getContentUri(String volumeName)
Get the content:// style URI for the image media table on the given volume.
getThumbnail(ContentResolver cr, long origId, long groupId, int kind, BitmapFactory.Options options)
This method checks if the thumbnails of the specified image (origId) has been created.
getThumbnail(ContentResolver cr, long origId, int kind, BitmapFactory.Options options)
This method checks if the thumbnails of the specified image (origId) has been created.
query(ContentResolver cr, Uri uri, String[] projection)
queryMiniThumbnail(ContentResolver cr, long origId, int kind, String[] projection)
queryMiniThumbnails(ContentResolver cr, Uri uri, int kind, String[] projection)
4.4 MediaStore.MediaColumns
大多數MediaProvider表的常見字段。
字段
解析
DATA
Path to the file on disk.
DATE_ADDED
The time the file was added to the media provider Units are seconds since 1970.
DATE_MODIFIED
The time the file was last modified Units are seconds since 1970.
DISPLAY_NAME
The display name of the file
HEIGHT
The height of the image/video in pixels.
MIME_TYPE
The MIME type of the file
SIZE
The size of the file in bytes
TITLE
The title of the content
WIDTH
The width of the image/video in pixels.
4.5 MediaStore.Video
包含視頻文件的元數據,并提供相應字段和方法。
方法
解析
query(ContentResolver cr, Uri uri, String[] projection)
4.5.1 MediaStore.Video.Media
提供和獲取視頻文件的Uri,繼承VideoColumns
字段
解析
CONTENT_TYPE
The MIME type for this table.
DEFAULT_SORT_ORDER
The default sort order for this table
EXTERNAL_CONTENT_URI
The content:// style URI for the "primary" external storage volume.
INTERNAL_CONTENT_URI
The content:// style URI for the internal storage.
方法
解析
getContentUri(String volumeName)
Get the content:// style URI for the video media table on the given volume.
4.5.2 MediaStore.Video.Thumbnails
這個類讓開發者去查詢并且得到兩種略縮圖:MINI_KIND: 512 x 384 thumbnail MICRO_KIND: 96 x 96 thumbnail
字段
解析
DATA
Path to the thumbnail file on disk.
DEFAULT_SORT_ORDER
The default sort order for this table
FULL_SCREEN_KIND
HEIGHT
The height of the thumbnail
KIND
The kind of the thumbnail
MICRO_KIND
MINI_KIND
VIDEO_ID
The original image for the thumbnal
WIDTH
The width of the thumbnal
EXTERNAL_CONTENT_URI
The content:// style URI for the "primary" external storage volume.
INTERNAL_CONTENT_URI
The content:// style URI for the internal storage.
方法
解析
cancelThumbnailRequest(ContentResolver cr, long origId)
This method cancels the thumbnail request so clients waiting for getThumbnail will be interrupted and return immediately.
cancelThumbnailRequest(ContentResolver cr, long origId, long groupId)
This method cancels the thumbnail request so clients waiting for getThumbnail will be interrupted and return immediately.
getContentUri(String volumeName)
Get the content:// style URI for the image media table on the given volume.
getThumbnail(ContentResolver cr, long origId, long groupId, int kind, BitmapFactory.Options options)
This method checks if the thumbnails of the specified image (origId) has been created.
getThumbnail(ContentResolver cr, long origId, int kind, BitmapFactory.Options options)
This method checks if the thumbnails of the specified image (origId) has been created.
4.5.3 MediaStore.Video.VideoColumns
代表所有視頻文件的列
字段
解析
ALBUM
The album the video file is from, if any
ARTIST
The artist who created the video file, if any
BOOKMARK
The bookmark for the video.
BUCKET_DISPLAY_NAME
The bucket display name of the video.
BUCKET_ID
The bucket id of the video.
CATEGORY
The YouTube category of the video
DATE_TAKEN
The date & time that the video was taken in units of milliseconds since jan 1, 1970.
DESCRIPTION
The description of the video recording
DURATION
The duration of the video file, in ms
IS_PRIVATE
Whether the video should be published as public or private
LANGUAGE
The language of the video
LATITUDE
The latitude where the video was captured.
LONGITUDE
The longitude where the video was captured.
MINI_THUMB_MAGIC
The mini thumb id.
RESOLUTION
The resolution of the video file, formatted as "XxY"
TAGS
The user-added tags associated with a video
最后編輯于 :2017.12.08 00:01:28
?著作權歸作者所有,轉載或內容合作請聯系作者 平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。