[英]Querying MediaStore.Images.Media , how do I query both on EXTERNAL_CONTENT_URI and INTERNAL_CONTENT_URI?
And first of all thanks for your help.首先感谢您的帮助。
I think this should be a rather trivial question for somebody not new to querying Content Providers.我认为对于不熟悉查询内容提供者的人来说,这应该是一个相当微不足道的问题。
I need to query MediaStore.Images.Media to obtain ALL the images on the device, both on internal storage and on an sd card.我需要查询MediaStore.Images.Media以获取设备上的所有图像,包括内部存储和 SD 卡。
This is the query I have in mind:这是我想到的查询:
String[] proj = { MediaStore.Images.Media.DATA };
actualimagecursor =
managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,null, null, null);
the point is that I want to query both EXTERNAL_CONTENT_URI and INTERNAL_CONTENT_URI.问题是,我想查询都EXTERNAL_CONTENT_URI和INTERNAL_CONTENT_URI。
Is it possible to perform it with a single query?是否可以通过单个查询执行它?
Sorry this is too old to help, but you can use MergeCursor to combine the two queries.抱歉,这太旧了,无法提供帮助,但您可以使用 MergeCursor 来组合这两个查询。
Cursor[] cursors = new Cursor[2];
cursors[0] = mActivity.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{
MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.ORIENTATION,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
MediaStore.Images.Media.BUCKET_ID,
MediaStore.Images.Media.MIME_TYPE ,
},
null,
null,
MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC"
);
cursors[1] = mActivity.getContentResolver().query(
MediaStore.Images.Media.INTERNAL_CONTENT_URI,
new String[]{
MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.ORIENTATION,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
MediaStore.Images.Media.BUCKET_ID,
MediaStore.Images.Media.MIME_TYPE
},
null,
null,
MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC"
);
Cursor cursor = new MergeCursor(cursors);
It's not possible to retrieve both results with a single query since the query is permofmed in a specific location (internal or external).由于查询是在特定位置(内部或外部)进行的,因此无法使用单个查询检索两个结果。 You need yo instantiate two dirrefent
Cursors
.你需要你实例化两个 dirrefent
Cursors
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.