i use this for save image From a gallery and copy to (/data/data/fshizzle_eval.com/files/image.jpg), work only if the image (/data/data/fshizzle_eval.com/files/image.jpg) already exists:
// Save
try {
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream("/data/data/fshizzle_eval.com/files/image.jpg"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if the image does not exist i this msg in my logcat and the image chosen from the gallery is not copied
07-06 21:44:48.839: WARN/System.err(3854): java.io.FileNotFoundException: /data/data/fshizzle_eval.com/files/image.jpg (No such file or directory)
How fix this please ?
You are trying to create a file in a folder that probably doesn’t exist. Check if the folder exists first. If not, create it, and then try writing to the file.
File file = new File("/data/data/fshizzle_eval.com/files"); if(!file.exists){ file.mkdirs(); }