Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; public class Main { public static void bitmap2file(Bitmap bitmap, String path) { try { // create a file to write bitmap data File f = new File(path); if (f.exists()) { f.delete(); f.createNewFile(); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(CompressFormat.JPEG, 30 /* ignored for PNG */, bos); byte[] bitmapdata = bos.toByteArray(); // write the bytes in file FileOutputStream fos = new FileOutputStream(f); fos.write(bitmapdata); fos.flush(); fos.close(); } catch (IOException e) { e.printStackTrace(); } } }