Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void saveBitmap(String path, Bitmap mBitmap) { File f = new File(path); if (!f.exists()) createDipPath(path); FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); try { fOut.flush(); } catch (IOException e) { e.printStackTrace(); } try { fOut.close(); } catch (IOException e) { e.printStackTrace(); } } public static void createDipPath(String file) { String parentFile = file.substring(0, file.lastIndexOf("/")); File file1 = new File(file); File parent = new File(parentFile); if (!file1.exists()) { parent.mkdirs(); try { file1.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } } }