Here you can find the source of saveBitmap(String bitName, Bitmap bitmap)
public static boolean saveBitmap(String bitName, Bitmap bitmap)
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Picture; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.view.View; import android.webkit.WebView; import android.widget.ScrollView; public class Main{ public static boolean saveBitmap(String bitName, Bitmap bitmap) { try {// w ww . jav a2 s . com File temp = File.createTempFile("temp", ".png", new File( StringUtil.getNameDelLastPath(bitName))); FileOutputStream fOut = null; try { fOut = new FileOutputStream(temp); } catch (FileNotFoundException e) { } bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); fOut.flush(); fOut.close(); if (temp.exists()) { File f = new File(bitName); if (f.exists()) { f.delete(); } FileUtil.moveFile(temp.getAbsolutePath(), bitName); } return true; } catch (IOException e) { e.printStackTrace(); } return false; } }