-1

check the image for more understanding and thanks in advance. In this screenshot all options are good but I don't want to display the document option here but also need a document to be picked. if there is not any way to hide the option then need help to get the path of file

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();
        }
    }
Amit Patel
  • 11
  • 2

1 Answers1

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