1

I'm trying to open my downloaded files on a specific path (my download folder in the app). Unfortunately, I do not know how to implement this method.I found this way by searching the Internet.

 ... } else if (id == R.id.nav_MyDownloads) {
    intent = new Intent(Intent.ACTION_GET_CONTENT);
    Uri uri = Uri.parse("storage/sdcard/pdfs"); // a directory
    intent.setDataAndType(uri, "*/*");
    startActivity(Intent.createChooser(intent, "Open folder"));;

}...

But when I use intent, I see the path of the recent files instead of the path I introduce, please guide me. thank you

Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69
Haj Ali
  • 93
  • 2
  • 11

1 Answers1

2

Did you tried this to get the directory path ?

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

If I got your question, what you want to achieve is this:

File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
Uri uri = Uri.parse(path.getAbsolutePath());

path.getAbsolutePath() gives you the Download folder path like this: /storage/emulated/0/Download

Alex Po
  • 58
  • 8
  • No, I did not use this command I use only a few lines to get to the folder, You can explain a little more about it? – Haj Ali Feb 07 '18 at 16:12
  • 1
    I'd recommend you explain what this line does fully. Otherwise, this should have been a comment. – Taslim Oseni Feb 07 '18 at 16:28
  • @Taslim Thank you, I was able to find the route. But I'm going to get the contents of this file. For example, I have 5 PDF files on this path and I want to open it in my program. What should I do now? – Haj Ali Feb 07 '18 at 17:59