在我的应用程序中,我创建了GridView
显示来自特定文件夹的图像。问题是我想从 DCIM/100ANDRO 文件夹中检索图像。应该通过查询传递哪种类型的参数来检索这种类型的图像?请给我解决方案。
我正在使用以下代码来检索这给了我相机捕获的图像
//importing only camera images and storing in ArrayList of class Images type
String[] projection = {
MediaStore.Images.Media._ID, MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
MediaStore.Images.Media.DISPLAY_NAME
};
String selection = MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " = ?";
String[] selectionArgs = new String[] {
"Camera"
};
Cursor mImageCursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, null );
if (mImageCursor != null)
{
mImageCursor.moveToFirst();
for (int i = 0; i < mImageCursor.getCount(); i++)
{
Images im=new Images();
eachImageView=new ImageView(this);
int imageId = mImageCursor.getInt((mImageCursor.getColumnIndex( MediaStore.Images.Media._ID)));
Bitmap bm = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(),
imageId, MediaStore.Images.Thumbnails.MINI_KIND, null);
im.setBitmap(bm);
eachImageView.setImageBitmap(bm);
im.setImageView(eachImageView);
arrayOfImages.add(im);
mImageCursor.moveToNext();
}
}
建议将不胜感激!