if (isMediaDocument(uri)) {
Log.e("URI", "" + uri);
final String docId = DocumentsContract.getDocumentId(uri);
Log.e("docId", "" + docId);
final String[] split = docId.split(":");
final String type = split[0];
Log.e("TYPE", "" + type);
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
} /*else if ("document".equals(type)) {
contentUri = uri;
}*/
selection = "_id=?";
selectionArgs = new String[]{split[1]};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
if (isGoogleDriveUri(uri)) {
return getDriveFilePath(context, uri);
}
if (isWhatsAppFile(uri)) {
return getFilePathForWhatsApp(context, uri);
}
if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
}
Asked
Active
Viewed 457 times
-1

Amit Patel
- 11
- 2
1 Answers
1
You cannot grey that option out.
And even if you would manage to implement your getRealPathForUri()
to deliver a file system path your app would not have read and write access on an Android 11+ device.
So what you want makes no sense.
Use the uri directly.
Every body does now adays.

blackapps
- 8,011
- 2
- 11
- 25