Oreo DocumentsContract.getDocumentId(uri) returns path instead of Long
Had the same problem solved it by doing the following.
final String id = DocumentsContract.getDocumentId(uri);if (!TextUtils.isEmpty(id)) { if (id.startsWith("raw:")) { return id.replaceFirst("raw:", ""); } try { final Uri contentUri = ContentUris.withAppendedId( Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); return getDataColumn(context, contentUri, null, null); } catch (NumberFormatException e) { return null; } }
Solution was found in a comment https://github.com/Yalantis/uCrop/issues/318
use this
String id = DocumentsContract.getDocumentId(uri); id = id.replaceAll("\\D+","");