Java tutorial
//package com.java2s; import android.os.Environment; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String JPG_EXTENSION = ".jpeg"; private static final String JPEG_FILE_PREFIX = "IMG"; public static File createImageFile() throws IOException { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = JPEG_FILE_PREFIX + timeStamp + "_"; return File.createTempFile(imageFileName, JPG_EXTENSION, getAlbumDir()); } public static File getAlbumDir() { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File storageDir = new File(dir, "MyAlbum"); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { return null; } } return storageDir; } else { return null; } } }