title: Android: File IO Errors
body: <p>The problem: on android 4.x I get weird errors when downloading images:</p>
  
  <pre><code>07-23 10:31:05.961: E/XXX(32294): libcore.io.ErrnoException: open failed: ENOENT (No such file or directory) 
  07-23 10:31:05.961: E/XXX(32294):  open failed: ENOENT (No such file or directory)
  </code></pre>
  
  <p>and sometimes:</p>
  
  <pre><code>07-23 10:31:06.133: W/System.err(32294): java.io.IOException: open failed: ENOENT (No such file or directory)
  07-23 10:31:06.133: W/System.err(32294):    at java.io.File.createNewFile(File.java:940)
  07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.JSON.Media.save(Media.java:55)
  07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.JSON.Media.setFile(Media.java:78)
  07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.ServerAccess.AsyncDownloadQueue$QueueMedia.isDone(AsyncDownloadQueue.java:257)
  07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.ServerAccess.AsyncDownloadQueue.doInBackground(AsyncDownloadQueue.java:102)
  07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.ServerAccess.AsyncDownloadQueue.doInBackground(AsyncDownloadQueue.java:1)
  07-23 10:31:06.133: W/System.err(32294):    at com.XXX.Library.Threading.AsyncTask$2.call(AsyncTask.java:189)
  07-23 10:31:06.133: W/System.err(32294):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  07-23 10:31:06.133: W/System.err(32294):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  07-23 10:31:06.133: W/System.err(32294):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
  07-23 10:31:06.133: W/System.err(32294):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
  07-23 10:31:06.133: W/System.err(32294):    at java.lang.Thread.run(Thread.java:856)
  07-23 10:31:06.133: W/System.err(32294): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
  07-23 10:31:06.141: W/System.err(32294):    at libcore.io.Posix.open(Native Method)
  07-23 10:31:06.141: W/System.err(32294):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
  07-23 10:31:06.141: W/System.err(32294):    at java.io.File.createNewFile(File.java:933)
  07-23 10:31:06.141: W/System.err(32294):    ... 11 more
  </code></pre>
  
  <p>So the weird bit... this works on android 2.2 AND it works SOMETIMES with an image here and there on 4.x. The exact same download routine will download one file, but not others. Are there limitations when multithreading io access? Each thread is attached to a unique file so I don't think that's the issue; nothing is reading from a file that is being written to.</p>
  
  <p>Oh and it shouldn't be a permission issue:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>