Android examples for android.graphics:Image Load Save
create Image File in External Storage
import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import android.os.Environment; public class Main { private static final String JPEG_FILE_SUFFIX = ".jpg"; private static final String JPEG_FILE_PREFIX = "IMG_"; static File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = JPEG_FILE_PREFIX + timeStamp + "_"; File albumF = getAlbumDir();//w w w .j av a 2 s . c o m File imageF = File.createTempFile(imageFileName, JPEG_FILE_SUFFIX, albumF); return imageF; } static private File getAlbumDir() { File storageDir = null; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { storageDir = new File("asdf"); if (storageDir != null) { if (!storageDir.mkdirs()) { if (!storageDir.exists()) { return null; } } } } return storageDir; } }