ビットマップがある Android アプリがあり、それをアプリケーション データ フォルダーに保存したいと考えています。ファイルは実行後にそこにありますが、その 0kb で画像は含まれていません。
バグはどこですか?
これが私のコードです:
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();
}