OpenInputStream Returning file not found exception but the file is there
<p>I am trying to scale a bitmap from an SD card and write it to phone memory. Then decode it at a later point to add it to <code>HashMap</code>. </p>

<p>The problem is that I am getting file not found exception although the path is right and the scaled image exists (I checked that)</p>

<p>Here is the saving part</p>

<pre><code>        Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream, null, options );         
        File imageRootPath = getFilesDir();
        File imageRoot = new File(imageRootPath, imagUri.getLastPathSegment()+".png");
        FileOutputStream out = new FileOutputStream(imageRoot);
        yourSelectedImage.compress(Bitmap.CompressFormat.PNG, 90, out);
</code></pre>

<p>And here is the part when I read the file</p>

<pre><code>try {
Uri mainImgeUri = Uri.parse(imageRoot.toString());
File imageFile = new File(mainImgeUri.toString());
if(imageFile.exists()){
   System.out.println("it does");
}
InputStream imageStream = ListPropertiesBaseActivity.this.getContentResolver().openInputStream(mainImgeUri); // I am getting file not found error

Bitmap yourSelectedImage =BitmapFactory.decodeStream(imageStream);
hmBitmap.put(ID, yourSelectedImage);
imageStream.close();
} catch (Exception e) {

e.printStackTrace();
}
</code></pre>

<p>Could it be that <code>OpenInputStream</code> can not read from internal phone memory? Or may be the image that resulted from saving is not good? </p>

<p>Although I was able to view it by manually browsing to the file and opening it</p>

<p>Please note that the System.out.Println is executed so it means the file exists</p>
