I am struggling to access files in downloads folder that user can select.
Using the following to give user to select file
Intent intent;
if (SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
} else {
intent = new Intent(Intent.ACTION_GET_CONTENT);
}
// Filter to only show results that can be "opened", such as a
// file (as opposed to a list of contacts or timezones)
intent.addCategory(Intent.CATEGORY_OPENABLE);
// Filter to show only application/pdf, using the image MIME data type.
intent.setType(PDF_MIME_TYPE);
if (activity != null) {
activity.startActivityForResult(intent, requestCode);
}
As you might know then the following method is called when user selects the file
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
(Expected): Please see the following I can get a decent path from selecting another folder I created "fromPC"(observe it is a file named:"815" and extension "PDF"):
(Problem): When doing the exact same code but selecting "Downloads" folder I only get "873" at the end but the file name I selected was "PaymentNotification" and extension "PDF":
Reading online but nothing quite as specific as this.
So I am not sure how to let user select a file example PDF from "Downloads" folder after the scope storage change in new Android thanks in advance for the answer?
If there are a way to get a "File"(java.io) from within the "onActivityResult" method it would also solve my problem?