title: Android - error opening file just created
body: <p>I'm new to android developement and trying to do some file IO. Whenever I run this block of code:</p>
  
  <pre><code>File meta = new File(context.getAppContext().getFilesDir(),"meta");
  meta.mkdirs();
  File dir = new File(meta,"subdir");
  File imageFile = new File(dir,"filename");
  Log.d("test",imageFile.getAbsolutePath());
  FileOutputStream outputStream = new FileOutputStream(imageFile);
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>    java.io.FileNotFoundException: /data/data/com.example.android.networkusage/files/meta/Greg and The Morning Buzz/artwork30.jpg: open failed: ENOENT (No such file or directory)
      at libcore.io.IoBridge.open(IoBridge.java:406)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:88)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:73)
      at com.example.android.networkusage.Podcast.downloadArtworkFromUrl(Podcast.java:117)
      at com.example.android.networkusage.Podcast.&lt;init&gt;(Podcast.java:93)
      at com.example.android.networkusage.JSONParser.parse(JSONParser.java:113)
      at com.example.android.networkusage.NetworkActivity.loadXmlFromNetwork(NetworkActivity.java:240)
      at com.example.android.networkusage.NetworkActivity.access$100(NetworkActivity.java:65)
      at com.example.android.networkusage.NetworkActivity$DownloadXmlTask.doInBackground(NetworkActivity.java:203)
      at com.example.android.networkusage.NetworkActivity$DownloadXmlTask.doInBackground(NetworkActivity.java:198)
      at android.os.AsyncTask$2.call(AsyncTask.java:264)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
      at java.util.concurrent.FutureTask.run(FutureTask.java:137)
      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
      at java.lang.Thread.run(Thread.java:856)
      Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
      at libcore.io.Posix.open(Native Method)
      at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
      at libcore.io.IoBridge.open(IoBridge.java:390)
      ... 16 more
  </code></pre>
  
  <p>The log even prints out the file's path as directed, so the file must exist! Why is this happening?</p>
  
  <p>Also, my app has internal and external write priviledges. </p>