Android MediaStore中的BUCKET_ID是什么?
我浏览了一些查询MediaStore.Images内容提供商并使用名为BUCKET_ID的列的代码:Android MediaStore中的BUCKET_ID是什么?,android,Android,我浏览了一些查询MediaStore.Images内容提供商并使用名为BUCKET_ID的列的代码: Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; String projection[] = { "DISTINCT " + MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.Images.Media.BUCKET_ID, MediaStore.Im
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String projection[] = {
"DISTINCT " + MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
MediaStore.Images.Media.BUCKET_ID,
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.DATA
};
String BUCKET_GROUP_BY = "1) GROUP BY 1,(2";
String BUCKET_ORDER_BY = "MAX(datetaken) DESC";
Cursor imagecursor = getContentResolver().query(uri, projection, BUCKET_GROUP_BY, null, BUCKET_ORDER_BY);
一般来说,这些列代表什么?有人能举例说明吗?文档中关于这些列的一行代码解释得很少BUCKET\u DISPLAY\u NAME
添加到API级别29
字符串存储桶\u显示\u名称
存储桶显示图像的名称。这是从数据列自动计算的只读属性
类型:文本
常量值:bucket\u display\u name
桶号
在API级别29中添加
字符串BUCKET\u ID
映像的存储桶id。这是从数据列自动计算的只读属性
类型:文本
常量值:bucket\u id
拍摄日期
添加到API级别29
字符串日期
自1970年1月1日以来以毫秒为单位拍摄图像的日期和时间
类型:整数
常量值:已获取日期存储桶\u显示\u名称
添加到API级别29
字符串存储桶\u显示\u名称
存储桶显示图像的名称。这是从数据列自动计算的只读属性
类型:文本
常量值:bucket\u display\u name
桶号
在API级别29中添加
字符串BUCKET\u ID
映像的存储桶id。这是从数据列自动计算的只读属性
类型:文本
常量值:bucket\u id
拍摄日期
添加到API级别29
字符串日期
自1970年1月1日以来以毫秒为单位拍摄图像的日期和时间
类型:整数
常量值:日期记录的文档对此非常不清楚,上面的答案是文档的复制粘贴。无论如何,我已经从以下评论中找到了答案:
// BUCKET_DISPLAY_NAME is a string like "Camera" which is the directory
// name of where an image or video is in. BUCKET_ID is a hash of the path
// name of that directory (see computeBucketValues() in MediaProvider for
// details). MEDIA_TYPE is video, image, audio, etc.
//
// The "albums" are not explicitly recorded in the database, but each image
// or video has the two columns (BUCKET_ID, MEDIA_TYPE). We define an
// "album" to be the collection of images/videos which have the same value
// for the two columns.
以下是computeBucketValues供参考:
/**
* @param data The input path
* @param values the content values, where the bucked id name and bucket display name are updated.
*
*/
private static void computeBucketValues(String data, ContentValues values) {
File parentFile = new File(data).getParentFile();
if (parentFile == null) {
parentFile = new File("/");
}
// Lowercase the path for hashing. This avoids duplicate buckets if the
// filepath case is changed externally.
// Keep the original case for display.
String path = parentFile.toString().toLowerCase();
String name = parentFile.getName();
// Note: the BUCKET_ID and BUCKET_DISPLAY_NAME attributes are spelled the
// same for both images and video. However, for backwards-compatibility reasons
// there is no common base class. We use the ImageColumns version here
values.put(ImageColumns.BUCKET_ID, path.hashCode());
values.put(ImageColumns.BUCKET_DISPLAY_NAME, name);
}
文档对此非常不清楚,上面的答案是文档的复制粘贴。无论如何,我已经从以下评论中找到了答案:
// BUCKET_DISPLAY_NAME is a string like "Camera" which is the directory
// name of where an image or video is in. BUCKET_ID is a hash of the path
// name of that directory (see computeBucketValues() in MediaProvider for
// details). MEDIA_TYPE is video, image, audio, etc.
//
// The "albums" are not explicitly recorded in the database, but each image
// or video has the two columns (BUCKET_ID, MEDIA_TYPE). We define an
// "album" to be the collection of images/videos which have the same value
// for the two columns.
以下是computeBucketValues供参考:
/**
* @param data The input path
* @param values the content values, where the bucked id name and bucket display name are updated.
*
*/
private static void computeBucketValues(String data, ContentValues values) {
File parentFile = new File(data).getParentFile();
if (parentFile == null) {
parentFile = new File("/");
}
// Lowercase the path for hashing. This avoids duplicate buckets if the
// filepath case is changed externally.
// Keep the original case for display.
String path = parentFile.toString().toLowerCase();
String name = parentFile.getName();
// Note: the BUCKET_ID and BUCKET_DISPLAY_NAME attributes are spelled the
// same for both images and video. However, for backwards-compatibility reasons
// there is no common base class. We use the ImageColumns version here
values.put(ImageColumns.BUCKET_ID, path.hashCode());
values.put(ImageColumns.BUCKET_DISPLAY_NAME, name);
}
这是从文档复制粘贴!请补充一些解释。正如Manish提到的,这些数据在文档中很容易获得。这是从文档复制粘贴!请补充一些解释。正如Manish所提到的,这些数据在文档中很容易获得。很棒的工作。这些应该是文件,而不是谷歌的伟大工作。这些应该是doc,而不是@Google