today I'm facing a problem while I try to import an external PDF into my app. This problem occurred only with Android 9 (and maybe 9+). Below the portion of code used to retrieve the file's path:
String[] proj = { MediaStore.Images.Media.DATA, OpenableColumns.DISPLAY_NAME };
Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
String path = cursor.getString(0); // <-- This is always null
//In the case it comes from Chrome
if(pathExternalFile.getAuthority().contains("chrome") || pathExternalFile.getAuthority().contains("fetcher"))
name = String.format("%s/%s", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), path);
else
name = path;
}
Does something change with Android 9? I have read the docs and seems to be all fine.