Java tutorial
//package com.java2s; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import android.graphics.Bitmap; import android.os.Environment; public class Main { public static String SDPATH = Environment.getExternalStorageDirectory() + "/EWealth/"; public static void saveBitmap(Bitmap bm, String picName) { try { if (!isFileExist("")) { createSDDir(""); } File f = new File(SDPATH, picName); if (f.exists()) { f.delete(); } FileOutputStream out = new FileOutputStream(f); bm.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static boolean isFileExist(String fileName) { File file = new File(SDPATH + fileName); file.isFile(); return file.exists(); } public static File createSDDir(String dirName) throws IOException { File dir = new File(SDPATH + dirName); if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { System.out.println("createSDDir:" + dir.getAbsolutePath()); System.out.println("createSDDir:" + dir.mkdir()); } return dir; } }