Friends, there is such a moment. I need to find out the path to the Downloads folder, if there is a flash drive then a flash drive, if not then the phone’s memory.

Folder Downloads from a flash drive, I take this code:

 Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) 

But on Sony Z2, this method does not work and I think there are many phones where this method does not work. (on the Sony Z2 flash drive was).

But, if there is no flash drive, how can I get the Downloads path on the phone's memory?

I need to download a PDF file to this directory, if I download to another location, the PDF Reader cannot open this file, although I check the directory for .canRead and .canWrite

There are many solutions on the Internet with the definition of a flash drive on different phones, but I did not find a normal solution.

  • You are in the right direction, all that is left for you is to check whether dir exists, if not, then create and record, if yes, then just write, in my opinion it is obvious. The code that you specified is just a request from the environment to form a standard path to the download folder for external media and no more than. - Shwarz Andrei
  • @ShwarzAndrei and how to make a request to the Download folder is not external media, but internal? - Iman

0