Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.os.Environment; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static boolean saveBitmapToLocal(String path, String fileName, Bitmap b) { if (b == null) { return false; } boolean result = false; String storageState = Environment.getExternalStorageState(); if (storageState.equals(Environment.MEDIA_MOUNTED)) { File dir = new File(path); if (!dir.exists()) { dir.mkdirs(); } FileOutputStream fos = null; try { fos = new FileOutputStream(path + fileName); b.compress(CompressFormat.JPEG, 100, fos); fos.flush(); result = true; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return result; } }