0

I'm writeing an XML file in android and I want to let the user select a folder, in the local storage( or SD card)

So i'm using this Intent:

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, READ_REQUEST_CODE);

everything work quite well, on "onActivityResult" method i'm getting this to get the folder choosed by the user:

final String path = data.getDataString();

but I get this:

content://com.android.providers.downloads.documents/tree/downloads

And when I continue and try to write I get this error:

Caused by: java.io.FileNotFoundException:

content:/com.android.providers.downloads.documents/tree/downloads/ATMob_Export_2019-06-03_16-29-01.zip

I suppose that I'll receive something like :

/storage/emulated/0/download

Any idea ?

Best Regards

Morteza Jalambadani
  • 2,190
  • 6
  • 21
  • 35
Nicolas400
  • 563
  • 1
  • 7
  • 29
  • Reading material: [Universal way to write to external SD card on Android](https://stackoverflow.com/q/40068984/295004) – Morrison Chang Jun 03 '19 at 19:59
  • See also https://stackoverflow.com/questions/48510584/onactivityresults-intent-getpath-doesnt-give-me-the-correct-filename and https://stackoverflow.com/questions/35870825/getting-the-absolute-file-path-from-content-uri-for-searched-images – CommonsWare Jun 03 '19 at 20:01

0 Answers0