public static Bitmap getBitmap(ContentResolver cr, String fileName) {
Bitmap bitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
// select condition.
String whereClause = MediaStore.Images.Media.DATA + " = '" + fileName
+ "'";
Cursor cursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[] { MediaStore.Images.Media._ID }, whereClause,
null, null);
if (cursor == null || cursor.getCount() == 0) {
if (cursor != null)
cursor.close();
return null;
}
cursor.moveToFirst();
// p_w_picpath id in p_w_picpath table.
String videoId = cursor.getString(cursor
.getColumnIndex(MediaStore.Images.Media._ID));
cursor.close();
if (videoId == null) {
return null;
}
long videoIdLong = Long.parseLong(videoId);
// via p_w_picpathid get the bimap type thumbnail in thumbnail table.
bitmap = MediaStore.Images.Thumbnails.getThumbnail(cr, videoIdLong,
Images.Thumbnails.MINI_KIND, options);
return bitmap;
}