I have a android app where I have a bitmap and I want to save it to the application data folder. The file is there after execution, but its 0kb and no picture is inside.
Where is the bug?
Here is my code:
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
myBitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
File f = new File(projDir + File.separator + newPath);
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
fo.close();
} catch (IOException e) {
e.printStackTrace();
}
add
fo.flush()