Android examples for Graphics:Bitmap File
Allocates a new bitmap file name in the Android filesystem.
//package com.java2s; import android.content.Context; import android.os.Environment; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**// w w w . ja v a2 s .c om * Allocates a new bitmap file in the Android filesystem. * @param context an application context * @return a File object pointing to the newly allocated file, null if the allocation fails */ public static File allocateImageFile(Context context) { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss") .format(new Date()); String fileName = "img_" + timeStamp; File storageDirectory = context .getExternalFilesDir(Environment.DIRECTORY_PICTURES); File image; try { image = File.createTempFile(fileName, ".jpg", storageDirectory); } catch (IOException e) { return null; } return image; } }