Issue
I want to know why this error comes when try to upload file with real device using Marshmallow. Can you please explain the solution for this.
12-28 10:39:32.606: E/3(17552): Excption : java.io.FileNotFoundException: /storage/emulated/0/WoodenstreetD.doc: open failed: ENOENT (No such file or directory)
I was stuck with this for last week and still getting same issue. Thanks In Advance.
Solution
This error comes due to wrong path. The path your getting from onActivityResult is not correct. Use this to get path of selected file.
public static String getRealPathFromUri(Context ctx, Uri uri) {
String[] filePathColumn = { MediaStore.Files.FileColumns.DATA };
Cursor cursor = ctx.getContentResolver().query(uri, filePathColumn,
null, null, null);
if (cursor != null) {
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
picturePath = cursor.getString(columnIndex);
Log.e("", "picturePath : " + picturePath);
cursor.close();
}
return picturePath;
}
picturePath gives you full path of image/file.
It'll work for me.
Answered By - user5685312