List of usage examples for android.os Environment DIRECTORY_PICTURES
String DIRECTORY_PICTURES
To view the source code for android.os Environment DIRECTORY_PICTURES.
Click Source Link
From source file:Main.java
/** Create a File for saving an image or video specific to an app name */ public static File getOutputMediaFile(int type, String optionalAppName) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. String appname = "CameraApp"; if (optionalAppName != null && !optionalAppName.isEmpty()) { appname = optionalAppName;/* w ww . j av a 2 s .c o m*/ } File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), appname); // This location works best if you want the created images to be shared // between applications and persist after your app has been uninstalled. // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) { mediaFile = new File( mediaStorageDir.getPath() + File.separator + "IMG_" + appname + timeStamp + ".jpg"); } else if (type == MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO) { mediaFile = new File( mediaStorageDir.getPath() + File.separator + "VID_" + appname + timeStamp + ".mp4"); } else { return null; } //USAGE: // fileUri = Helpers.getOutputMediaFileUri( // MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE, // Helpers.getApplicationName(this) // ); // create a file to save the image return mediaFile; }
From source file:Main.java
/** * Create a File for saving an image or video */// w w w . j a v a 2 s. com @SuppressLint("SimpleDateFormat") public static File getOutputMediaFile(int type, Context context) { // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile = null; if (type == MEDIA_TYPE_IMAGE) { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "StoryCapture"); if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("StoryCapture", "failed to create directory"); return null; } } mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); } else if (type == MEDIA_TYPE_AUDIO) { String fileName = "AUDIO_" + timeStamp + ".3gp"; mediaFile = new File(context.getFilesDir(), fileName); } return mediaFile; }
From source file:Main.java
public static File getAlbumStorageDir() { // Get the directory for the user's public pictures directory. File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), FOLDER); return file;/*from w ww . ja v a 2s . c o m*/ }
From source file:Main.java
/** Create a File for saving an image or video */ private static File getOutputMediaFile(int type) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "MyCameraApp"); // This location works best if you want the created images to be shared // between applications and persist after your app has been uninstalled. // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("MyCameraApp", "failed to create directory"); return null; }/*from w w w .j a v a2 s . c o m*/ } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); } else if (type == MEDIA_TYPE_VIDEO) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "VID_" + timeStamp + ".mp4"); } else { return null; } return mediaFile; }
From source file:Main.java
/** * Creates a thumbnail file starting from an image/video file * * @param original_file original file path * @param video true if the file is a video. false if the file is a picture * @return a file//from w w w. ja v a2 s . c o m */ private static File generateThumbnailFileForFile(File original_file, boolean video) { // Create an image file name try { String imageFileName = "thumb" + original_file.getName(); Log.d(TAG, original_file.getName()); File storageDir = Environment.getExternalStoragePublicDirectory( video ? Environment.DIRECTORY_MOVIES : Environment.DIRECTORY_PICTURES); return File.createTempFile(imageFileName, /* prefix */ THUMB_FORMAT_EXTENSION, /* suffix */ storageDir /* directory */ ); } catch (IOException e) { Log.d(TAG, "Error", e); } return null; }
From source file:Main.java
private static File getAlbumDir() { File storageDir = null;//from ww w . j a v a 2s . c o m if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Telepathy"); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { Log.d("android_utilities", "failed to create directory"); return null; } } } else { Log.d("android_utilities", "External storage is not mounted READ/WRITE."); } return storageDir; }
From source file:Main.java
/** Create a File for saving an image or video specific to an app name */ public static File getOutputMediaFile(int type, String optionalAppName) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. String appname = "CameraApp"; if (optionalAppName != null && !optionalAppName.isEmpty()) { appname = optionalAppName;// w w w . j a va2s . co m } File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), appname); // This location works best if you want the created images to be shared // between applications and persist after your app has been uninstalled. // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) { mediaFile = new File( mediaStorageDir.getPath() + File.separator + "IMG_" + appname + timeStamp + ".jpg"); } else if (type == MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO) { mediaFile = new File( mediaStorageDir.getPath() + File.separator + "VID_" + appname + timeStamp + ".mp4"); } else { return null; } return mediaFile; }
From source file:Main.java
public static File getOutputMediaFile(final int type) { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Dove"); //.delete();//from w w w .ja va 2 s . c o m if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); } else if (type == MEDIA_TYPE_VIDEO) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "VID_" + timeStamp + ".mp4"); } else { return null; } return mediaFile; }
From source file:Main.java
private static File getAlbumDir() { File storageDir = null;/*from w ww .ja va2 s .c o m*/ if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Telegram"); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { // FileLog.d("tmessages", "failed to create directory"); return null; } } } else { // FileLog.d("tmessages", "External storage is not mounted READ/WRITE."); } return storageDir; }
From source file:Main.java
public static String getCachePath() { return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath() + File.separator + "MyCamera"; }