I want to to get the image name while getting the image from gallery . How to do that? Below is my code. I have no idea how to proceed.
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, IMAGE_PICKER_SELECT);
}
});
return v;
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IMAGE_PICKER_SELECT && resultCode == Activity.RESULT_OK) {
bitmap = getBitmapFromCameraData(data, mainActivity);
bitmap = getBitmapFromCameraData(data, mainActivity);
profileImageView.setImageBitmap(bitmap);
uploadImage();
}
}
private Bitmap getBitmapFromCameraData(Intent data, Context context) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = context.getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
return BitmapFactory.decodeFile(picturePath);
}