Java tutorial
//package com.java2s; //License from project: Open Source License import android.os.Environment; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /** * Create an default file for save image from camera. * * @return * @throws IOException */ public static File createDefaultImageFile() throws IOException { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); String imageFileName = "JPEG_" + timeStamp + ".jpg"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (!storageDir.exists()) { storageDir.mkdirs(); } return new File(storageDir, imageFileName); } }