title: Android writing bitmap to sdcard
body: <p>I'm trying to write a bitmap to an sdcard on android, and I get the error message of <br>
  <code>/mnt/sdcard/PhysicsSketchpad/sketchpad145.png (No such file or directory).</code> <br>
  I declared the <code>android.permission.WRITE_EXTERNAL_STORAGE</code> permission in the manifest, and this is my code:</p>
  
  <pre><code>String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() + 
                          "/PhysicsSketchpad/";
  File dir = new File(file_path);
  dir.mkdirs();
  File file = new File(dir, "sketchpad" + pad.t_id + ".png");
  FileOutputStream fOut = new FileOutputStream(file);
  
  bmp.compress(Bitmap.CompressFormat.PNG, 85, fOut);
  fOut.flush();
  fOut.close();
  </code></pre>
  
  <p>What's going on?</p>
  
  <p><strong><em>UPDATE</em></strong></p>
  
  <p>It seems as though when I try to write to an existing directory, I get an permission denied error,<br></p>
  
  <pre><code>08-11 09:55:23.796: WARN/Physics Sketchpad(8881): Error when saving: IOException /mnt/sdcard/download/sketchpad54.png (Permission denied)
  </code></pre>
  
  <p>and when I try to save in a new directory I get a no such file or directory error,<br> <code>08-11 09:59:20.175: WARN/Physics Sketchpad(9040): Error when saving: IOException /mnt/sdcard/PhysicsSketchpad/sketchpad55.png (No such file or directory)</code></p>
  
  <p>In addition, <code>File.mkdirs()</code> returns a boolean based on if it succeeded or not, and it returned false.</p>