I have this error when i try to :
File file = new File(cacheDir, fileName);
Bitmap bmp = BitmapFactory.decodeFile(file.getAbsolutePath());
cache dir is from :
context.getCacheDir();
And the error is:
11-30 12:38:34.029: E/BitmapFactory(18814): Unable to decode stream: java.io.FileNotFoundException: /data/data/com.android.test/cache/file_name: open failed: ENOENT (No such file or directory)
This is my void to write the file:
public static void writeFile(Bitmap bmp, File f) {
if (bmp == null)
return;
FileOutputStream out = null;
try {
out = new FileOutputStream(f);
bmp.compress(Bitmap.CompressFormat.PNG, 80, out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null)
out.close();
} catch (Exception ex) {
}
}
Log.i("app", "path: "+f.getAbsolutePath());
}
In this void, the Log.i in the end print the same file path as the error one.
I have this error ONLY on device with android 4.2. till android 4.1.x all works fine.