Androidでサムネイル取得

Galleryとかを作る際に実画像を個々に小さくすると不可がかかるのでサムネイルを使用

//サムネイルを取得(96×96)
ContentResolver cr = getContentResolver();
Uri uri = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI;
//条件を指定しないと小さいサムネイル?と大きいサムネイル両方取得される
StringBuilder where = new StringBuilder();
where.append(MediaStore.Images.Thumbnails.KIND).append(” == “).append(Integer.toString((MediaStore.Images.Thumbnails.MICRO_KIND)));
String selection = where.toString();

Cursor cursor = cr.query(uri, null, selection, null, null);
cursor.moveToFirst();
for(int i = 0; i < cursor.getCount(); i++){
//画像パス
String path = cursor.getString(cursor.getColumnIndexOrThrow(“_data”));
//画像ID
long imageId = cursor.getLong(cursor.getColumnIndexOrThrow(“image_id”));

//サムネイル取得
Bitmap bmp = MediaStore.Images.Thumbnails.getThumbnail(cr,imageId, MediaStore.Images.Thumbnails.MICRO_KIND,null);
/////////////////////////////////////////
/ もろもろの処理
///////////////////////////////////////
cursor.moveToNext();
}

        //サムネイルを取得(96×96)
ContentResolver cr = getContentResolver();
Uri uri = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI;
StringBuilder where = new StringBuilder();
where.append(MediaStore.Images.Thumbnails.KIND).append(” == “).append(Integer.toString((MediaStore.Images.Thumbnails.MICRO_KIND)));
String selection = where.toString();        Cursor cursor = cr.query(uri, null, selection, null, null);
cursor.moveToFirst();
for(int i = 0; i < cursor.getCount(); i++){
String path = cursor.getString(cursor.getColumnIndexOrThrow(“_data”));
long imageId = cursor.getLong(cursor.getColumnIndexOrThrow(“image_id”));
Bitmap bmp = MediaStore.Images.Thumbnails.getThumbnail(cr,imageId, MediaStore.Images.Thumbnails.MICRO_KIND,null);
_thumbW = bmp.getWidth();
_thumbH = bmp.getHeight();
Map<String,Bitmap>tmpMap = new HashMap<String,Bitmap>();
tmpMap.put(path, bmp);
_listData.add(tmpMap);
cursor.moveToNext();
}