Here you can find the source of storeImage(Context context, Bitmap image)
public static void storeImage(Context context, Bitmap image)
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.os.Environment; import java.io.File; import java.io.FileOutputStream; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void storeImage(Context context, Bitmap image) { File pictureFile = getOutputMediaFile(context); if (pictureFile == null) return; try {// w w w.j av a2 s. c o m FileOutputStream fos = new FileOutputStream(pictureFile); image.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.close(); } catch (Exception e) { e.printStackTrace(); } } private static File getOutputMediaFile(Context context) { File mediaStorageDir = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm") .format(new Date()); File mediaFile; String mImageName = "TCG_" + timeStamp + ".jpg"; mediaFile = new File(mediaStorageDir.getPath() + File.separator + mImageName); return mediaFile; } }