1

In my app I need to open a file which I choose by Intent

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(Intent.createChooser(intent, "Complete action using"), 1);

it's a .docx file and to parse it I need to open a FileInputStream, but I can't get a proper path from URI I get

Logs

content://com.android.externalstorage.documents/document/primary%3Adata.docx
content:/com.android.externalstorage.documents/document/primary%3Adata.docx (No such file or directory)

I tried a few methods, but they didn't help me. So how I can do it?

Thanks for advance

Stephen Docy
  • 4,738
  • 7
  • 18
  • 31
Dima Zhylko
  • 65
  • 2
  • 8
  • 1
    https://commonsware.com/blog/2016/03/15/how-consume-content-uri.html https://stackoverflow.com/a/19985374/1048340 https://stackoverflow.com/a/5657557/1048340 – Jared Rummler Jan 27 '18 at 21:06
  • If an `InputStream` will suffice, use a `ContentResolver` and `openInputStream()`. If you need a file, make a local copy of the content, as is outlined in the duplicate question. – CommonsWare Jan 27 '18 at 21:08

0 Answers0