'Cannot choose files from storage from downloads
I need help. I cannot choose files from downloads, but from another folder from storage I can. In the screen in downloads, I can see files, but there are not available for choosing. What is my mistake? here is my code:
String[] mimeTypes = new String[]{PDF_MIME_TYPE, MP4_MIME_TYPE, MKV_MIME_TYPE,
AVI_MIME_TYPE, MOV_MIME_TYPE, DOCX_MIME_TYPE, XLSX_MIME_TYPE, PPTX_MIME_TYPE};
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
startActivityForResult(intent, "12");
Solution 1:[1]
Thanks to @blackapps, I removed mime types and added additional permissions:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_FROM_DIALOG);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Elikill58 |

