Code example for Activity

Methods: managedQuery

0
		Bitmap bitmap = null;
		 
        String[] proj = { MediaStore.Images.Media._ID,
                        MediaStore.Images.Media.DISPLAY_NAME };
         
        Cursor cursor = context.managedQuery(
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
                        MediaStore.Images.Media.DISPLAY_NAME + "='" + imgName +"'", null, null);
        
        if ( cursor!=null && cursor.getCount()>0 && cursor.moveToFirst() ) 
        { 
        	ContentResolver crThumb = context.getContentResolver();
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = 1;
            bitmap = MethodsCompat.getThumbnail(crThumb, cursor.getInt(0), kind, options);
        }  
        return bitmap;
	} 
	 
    public static Bitmap loadImgThumbnail(String filePath, int w, int h) {
    	Bitmap bitmap = getBitmapByPath(filePath);