Java tutorial
//package com.java2s; import android.graphics.Bitmap; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static String saveFile(Bitmap bm, String dirPath, String fileName, int scale) { File dirFile = new File(dirPath); if (!dirFile.exists()) { dirFile.mkdirs(); } File myCaptureFile = new File(dirPath + fileName); try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile)); bm.compress(Bitmap.CompressFormat.JPEG, scale, bos); bos.flush(); bos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return dirPath + fileName; } }