siralam / BSImagePicker

An image picker that extends BottomSheetDialogFragment. Camera and gallery all in one dialog. Single or Multi Selection.
201 stars 62 forks source link

Getting No Such File or Directory #51

Open Mfdsix opened 4 years ago

Mfdsix commented 4 years ago

when i try to make new File object from returned Uri, i got error No Such File or Directory. How can i fix this ?

Toprakete commented 4 years ago

when i try to make new File object from returned Uri, i got error No Such File or Directory. How can i fix this ?

I use this function to convert uri to real path, while contentURI is the uri passed from bsimagepicker

private String getRealPathFromURI(Uri contentURI) { String result=contentURI.getPath(); Cursor cursor = getActivity().getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { // Source is Dropbox or other similar local file path result = contentURI.getPath(); } else { if (cursor.moveToFirst()) { result = cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA)); } cursor.close(); } return result; }