Code example for ContentResolver

Methods: openFileDescriptor

0
Uri uri =  Uri.parse("content://media/external/audio/media/" + key + "/albumart");
			ContentResolver res = mContext.getContentResolver();
 
			try { 
				ParcelFileDescriptor parcelFileDescriptor = res.openFileDescriptor(uri, "r");
				if (parcelFileDescriptor != null) {
					FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
					return BitmapFactory.decodeFileDescriptor(fileDescriptor, null, BITMAP_OPTIONS);
				} 
			} catch (Exception e) {
				// no cover art found 
			} 
 
			return null; 
		} 
 
		@Override 
		protected int sizeOf(Long key, Bitmap value)
		{ 
			return value.getRowBytes() * value.getHeight();