what's this bug with writing image to file?
<p>I want to store image from url to the device</p>

<p>then I wrote some code below:</p>

<pre><code>    private void DownloadFromUrl(String downloadUrl, String fname) {

    try {

        File root = android.os.Environment.getExternalStorageDirectory();

        File dir = new File(root.getAbsolutePath() + "/myAlbum/");
        if (dir.exists() == false) {
            dir.mkdirs();
        }

        URL url = new URL(downloadUrl); 
        File file = new File(dir, fname);
        if(file.exists()) {
            showToast("already stored");
            return;
        }
        long startTime = System.currentTimeMillis();

        URLConnection ucon = url.openConnection();
        InputStream is = ucon.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        ByteArrayBuffer baf = new ByteArrayBuffer(10000);
        int current = 0;
        while ((current = bis.read()) != -1) {
            baf.append((byte) current);
        }

        /* Convert the Bytes read to a String. */
        FileOutputStream fos = new FileOutputStream(file);
        fos.write(baf.toByteArray());
        fos.flush();
        fos.close();
    } catch (IOException e) {
        Log.d("DownloadManager", "Error: " + e);
    }
}
</code></pre>

<p>and add permission in Menifest.</p>

<p>When the download is finished, I can't found the file in device</p>

<p>but it truly appears in DDMS mode</p>

<p>I can find the file path, name and size in DDMS</p>

<p>but it is not exist in device</p>

<p>What is wrong in my code?</p>

<p>Menifest here: <a href="https://dl.dropbox.com/u/90416799/menifest.jpg" rel="nofollow">menifest.xml screen shot</a></p>
