Java tutorial
//package com.java2s; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import android.graphics.Bitmap; import android.util.Log; public class Main { public static void saveBitmapToFile(Bitmap bitmap, String _file) throws IOException { BufferedOutputStream os = null; try { File file = new File(_file); // String _filePath_file.replace(File.separatorChar + // file.getName(), ""); int end = _file.lastIndexOf(File.separator); String _filePath = _file.substring(0, end); File filePath = new File(_filePath); if (!filePath.exists()) { filePath.mkdirs(); } file.createNewFile(); os = new BufferedOutputStream(new FileOutputStream(file)); bitmap.compress(Bitmap.CompressFormat.PNG, 100, os); } finally { if (os != null) { try { os.close(); } catch (IOException e) { Log.e("TAG_ERROR", e.getMessage(), e); } } } } }