I am try to pick an image from gallery and set in image view in FRAGMENT. But I am getting the value of picture path perfectly but i am unable to get value bitmap(It gives null value). Note:The main problem is bitmap giving null value and not Nullpointer exception.
Intent i = new Intent(
Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getActivity().getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
Bitmap b= BitmapFactory.decodeFile(picturePath);
Here is my logcat:
> 07-20 17:28:02.832 24228-24228/com.hello42 I/personal details: hello
> cursor android.content.ContentResolver$CursorWrapperInner@ee7b2c5
> 07-20 17:28:02.832 24228-24228/com.hello42 I/personal details: hello
> -- picturepath /storage/emulated/0/DCIM/Camera/IMG_20160716_155012_1.jpg 0 07-20
> 17:28:02.837 24228-24228/com.hello42 I/personal details: hello --
> bitmap null