Java tutorial
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.UUID; import android.graphics.Bitmap; import android.os.Environment; public class Main { public static boolean saveToSDCard(Bitmap bitmap) { if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { return false; } FileOutputStream fileOutputStream = null; File file = new File("/sdcard/myName/Download/"); if (!file.exists()) { file.mkdirs(); } String fileName = UUID.randomUUID().toString() + ".jpg"; String filePath = "/sdcard/myName/Download/" + fileName; File f = new File(filePath); if (!f.exists()) { try { f.createNewFile(); fileOutputStream = new FileOutputStream(filePath); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream); } catch (IOException e) { return false; } finally { try { fileOutputStream.flush(); fileOutputStream.close(); } catch (IOException e) { return false; } } } return true; } }