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
public static String getOutputMediaFolderPath() { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { return null; }//w w w. j a v a 2 s. co m File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "HDMIRxDemo"); // 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("CameraSample", "failed to create directory"); return null; } } // return path string of the folder return mediaStorageDir.getAbsolutePath(); }
From source file:Main.java
/** * Save an image URI into the gallery//from w w w . j ava 2 s. c om * @param context the context. * @param sourceFile the image path to save. */ public static String saveImageIntoGallery(Context context, File sourceFile) { String filePath = saveFileInto(context, sourceFile, Environment.DIRECTORY_PICTURES, null); if (null != filePath) { // This broadcasts that there's been a change in the media directory context.sendBroadcast( new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(filePath)))); } return filePath; }
From source file:Main.java
/** * get the directory to save photos in/*from w w w .ja v a 2 s .c om*/ * @return */ private static File getAppDir() { File sdDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); return new File(sdDir, "SjirkSudoku"); }
From source file:Main.java
/** * Gets a bitmap from a path inside the TexturePoemApp-Folder * @param path path of the bitmap inside the TexturePoemApp-Folder * @return Decoded bitmap //from w w w .jav a 2s . co m */ public static Bitmap getBitmapFromPath(String path) { Bitmap b = null; if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { String galleryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) .toString(); File f = new File(galleryPath + "/TexturePoemApp/" + path); if (f.exists()) { b = BitmapFactory.decodeFile(f.getAbsolutePath()); } } return b; }
From source file:Main.java
public static File getAlbumDirectory(String albumName) { File albumDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), albumName);/*from w ww . ja va2 s . c o m*/ if (!createExternalStorageDirectory(albumDir)) { return null; } return albumDir; }
From source file:Main.java
/** * Creates a File from a Bitmap//from w w w . ja va2 s. co m * * @param bitmap to convert in a file * * @return File */ public static File createFileFromBitmap(Bitmap bitmap) { if (bitmap == null) return null; File photoFile = null; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes); File photoStorage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (photoStorage != null) { photoFile = new File(photoStorage, (System.currentTimeMillis()) + ".png"); try { //f.createNewFile(); FileOutputStream fo = new FileOutputStream(photoFile); fo.write(bytes.toByteArray()); fo.flush(); fo.close(); } catch (IOException e) { Log.e(TAG, "Error saving image ", e); } } return photoFile; }
From source file:Main.java
/** * Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory * is persistent and available to other applications like gallery. * * @param type Media type. Can be video or image. * @return A file object pointing to the newly created file. *//* w ww . ja va 2 s. c om*/ public static File getOutputMediaFile(int type) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { return null; } File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "mapiary"); // 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("CameraSample", "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
/** * Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory * is persistent and available to other applications like gallery. * * @param type Media type. Can be video or image. * @return A file object pointing to the newly created file. *///w ww. j a va 2 s . c om public static File getOutputMediaFile(int type) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { return null; } File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "CameraSample"); // 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("CameraSample", "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
/** * Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory * is persistent and available to other applications like gallery. * * @param type Media type. Can be video or image. * @return A file object pointing to the newly created file. *//*from w w w . ja va2 s . c o m*/ public static File getOutputMediaFile(int type, String token, String extension) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { return null; } File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "FloatingWindow2"); // 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("CameraSample", "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 + "-" + token + extension); } else { return null; } return mediaFile; }
From source file:Main.java
/** * Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory * is persistent and available to other applications like gallery. * * @param type Media type. Can be video or image. * @return A file object pointing to the newly created file. *//*from www. ja v a 2 s . c om*/ public static File getOutputMediaFile(int type) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { return null; } File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "CameraSample"); // 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("CameraSample", "failed to create directory"); return null; } } // Create a media file name @SuppressLint("SimpleDateFormat") 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; }