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; public class Main { public static void saveBitmapToFile(Bitmap bitmap, String filePath) throws IOException { makeDirsByFilePath(filePath); File bitmapFile = new File(filePath); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(bitmapFile)); bitmap.compress(Bitmap.CompressFormat.PNG, 80, bos); bos.flush(); bos.close(); } public static void makeDirsByFilePath(String filePath) { String path = filePath.substring(0, filePath.lastIndexOf("/")); makeDirsByPath(path); } public static void makeDirsByPath(String path) { File dirFile = null; dirFile = new File(path); if (!dirFile.exists()) { dirFile.mkdirs(); } dirFile = null; } }