I am going to develop an app, where user can choose File from a Download directory. Now i need the path + name of the file, which the user has chosen.
DownloadManager dm = (DownlaodManager) getSystemService(DOWNLOAD_SERVICE);
By this way the user can choose the file. Now i need the absoloute path of the file, which is choosen. But the problem here is, if the user chosse a file, the file will be open(this shouldn't be happen)
Can anyone of you help me with that?
Use,
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
to access the folder, andFile.listFiles()
to access individual files from that directory.See this rough example,
write a method to browse and list each file from
Downloads
directory, and if a directory is found inDownloads
folder, list its files too,Get the path of your
Downloads
directory and pass it as parameter in your above method,Don't forget you'll need to set this permission in your manifest:
You can use WRITE_EXTERNAL_STORAGE instead.