Save an edited image to the SD card
<p>I'm opening an image from the gallery, resizing it, and attempting to save the resized version to the apps data file so I can grab it in future. My problem is I keep getting a FileNotFoundException when I try to write it with an input stream.</p>

<p>This is the file it's trying to write too. "/mnt/sdcard/Android/data/foundcake.myslide/files/IMG_20100918_133128.png"</p>

<p>Am I missing any important steps here?</p>

<pre><code>    File storagePath = new File(Environment.getExternalStorageDirectory() + "/Android/data/foundcake.myslide/files/");
    storagePath.mkdirs();

    Debug.print("STORAGE PATH " + storagePath);

    Pattern pattern = Pattern.compile("/([^/]+)\\.[^/]+$");
    Matcher matcher = pattern.matcher(filePath);
    String fileName = "";
    while (matcher.find()) {
        fileName = matcher.group(1);
    }

    Debug.print("FILE NAME " + fileName);

    File cached = new File(storagePath, fileName + ".png");

    Debug.print("NEW FILE " + cached.toString());

    try {
        FileOutputStream out = new FileOutputStream(cached);
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
    } catch (Exception e) {
        e.printStackTrace();
    }
</code></pre>
