Here you can find the source of saveBitmapToFile(Bitmap bitmap, String filename)
public static boolean saveBitmapToFile(Bitmap bitmap, String filename)
//package com.java2s; import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static boolean saveBitmapToFile(Bitmap bitmap, String filename) { boolean result = false; FileOutputStream fos = null; try {/*from ww w. jav a 2 s.c o m*/ fos = new FileOutputStream(new File(filename)); fos.write(bitmap2byte(bitmap)); result = true; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (null != fos) { fos.close(); } } catch (IOException e) { e.printStackTrace(); } } return result; } public static byte[] bitmap2byte(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); return baos.toByteArray(); } }