Store the content of a Bitmap in a file.
[Java]
// Create a file to write bitmap data
File f = File (context. getCacheDir (), filename );
F. createNewFile ();
// Convert bitmap to byte array
Bitmap bitmap = your bitmap;
ByteArrayOutputStream bos = new ByteArrayOutputStream ();
Bitmap. compress (CompressFormat. PNG, 0/* ignored for PNG */, bos );
Byte [] bitmapdata = bos. toByteArray ();
// Write the bytes in file
FileOutputStream fos = new FileOutputStream (f );
Fos. write (bitmapdata );
// Create a file to write bitmap data
File f = File (context. getCacheDir (), filename );
F. createNewFile ();
// Convert bitmap to byte array
Bitmap bitmap = your bitmap;
ByteArrayOutputStream bos = new ByteArrayOutputStream ();
Bitmap. compress (CompressFormat. PNG, 0/* ignored for PNG */, bos );
Byte [] bitmapdata = bos. toByteArray ();
// Write the bytes in file
FileOutputStream fos = new FileOutputStream (f );
Fos. write (bitmapdata); Train of Thought: input the content of Bitmap to the output stream, and then output the data from the output stream to the file.