ENOENT / FileNotFoundException Upon Using ContentResolver on URI

Viewed 277

Error(s) are:

Caused by android.system.ErrnoException
open failed: ENOENT (No such file or directory)

And

Non-fatal Exception: java.io.FileNotFoundException
/storage/emulated/0/Download/File-16.ext: open failed: ENOENT (No such file or directory)

(File name/extension changed slightly for privacy.)


The line of code is simply

inputStream = getContentResolver().openInputStream(data);

Where data is the non-null URI intent.getData();

It works for 99% of users, but there's quite a few that report this crash silently. I can't figure out why though?

I've logged some of the URIs that cause this but see no pattern:

  • file:///storage/emulated/0/Download/File-16.ext
  • file:///storage/emulated/0/Download/12APK%2BOBB.NESTV.zip
  • file:///storage/emulated/0/Download/Figure%20Submission%20umdertale
  • content://com.google.android.apps.searchlite.fileprovider/downloadfile/storage/emulated/0/Download/MKX-Scorpion-vs-Sub-Zero.zip
  • content://downloads/all_downloads/2249

Also no consistency in device/android version either. Can't find any questions on this, only questions with answers saying to use ContentResolver on URIS, which I am in this case.

0 Answers
Related