Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.os.Environment; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Random; public class Main { public static void saveImage(Bitmap bmp) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/abcxyz"); myDir.mkdirs(); Random generator = new Random(); int n = 10000; n = generator.nextInt(n); String name = "Image-" + n + ".jpg"; File file = new File(myDir, name); if (file.exists()) file.delete(); try { FileOutputStream out = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }