Java Code Examples for android.os.Environment#DIRECTORY_DCIM
The following examples show how to use
android.os.Environment#DIRECTORY_DCIM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UtilsHandler.java From PowerFileExplorer with GNU General Public License v3.0 | 9 votes |
public void addCommonBookmarks() { String sd = Environment.getExternalStorageDirectory() + "/"; String[] dirs = new String[] { sd + Environment.DIRECTORY_DCIM, sd + Environment.DIRECTORY_DOWNLOADS, sd + Environment.DIRECTORY_MOVIES, sd + Environment.DIRECTORY_MUSIC, sd + Environment.DIRECTORY_PICTURES }; for (String dir : dirs) { addBookmark(new File(dir).getName(), dir); } }
Example 2
Source File: ScopedDirectoryAccessFragment.java From android-ScopedDirectoryAccess with Apache License 2.0 | 8 votes |
private String getDirectoryName(String name) { switch (name) { case "ALARMS": return Environment.DIRECTORY_ALARMS; case "DCIM": return Environment.DIRECTORY_DCIM; case "DOCUMENTS": return Environment.DIRECTORY_DOCUMENTS; case "DOWNLOADS": return Environment.DIRECTORY_DOWNLOADS; case "MOVIES": return Environment.DIRECTORY_MOVIES; case "MUSIC": return Environment.DIRECTORY_MUSIC; case "NOTIFICATIONS": return Environment.DIRECTORY_NOTIFICATIONS; case "PICTURES": return Environment.DIRECTORY_PICTURES; case "PODCASTS": return Environment.DIRECTORY_PODCASTS; case "RINGTONES": return Environment.DIRECTORY_RINGTONES; default: throw new IllegalArgumentException("Invalid directory representation: " + name); } }
Example 3
Source File: FileUtils.java From Simpler with Apache License 2.0 | 7 votes |
/** * 创建根缓存目录 * * @return */ public static String getRootPath(Context context) { String rootPath = ""; if (isSdCardAvailable()) { // 图片保存到相册 rootPath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + Environment.DIRECTORY_DCIM + File.separator + "Camera"; File file = new File(rootPath); if (!file.exists()) { file.mkdirs(); } } else { // /data/data/<application package>/cache rootPath = context.getCacheDir().getPath(); } return rootPath; }
Example 4
Source File: FileUtils.java From filemanager with MIT License | 6 votes |
public static boolean isMediaDirectory(File file) { try { String path = file.getCanonicalPath(); for (String directory : new String[]{Environment.DIRECTORY_DCIM, Environment.DIRECTORY_MUSIC, Environment.DIRECTORY_PICTURES}) { if (path.startsWith(Environment.getExternalStoragePublicDirectory(directory) .getAbsolutePath())) return true; } return false; } catch (IOException e) { e.printStackTrace(); return false; } }
Example 5
Source File: CommonUtils.java From Simpler with Apache License 2.0 | 5 votes |
/** * 拍照 */ public static String capture(Activity activity, int requestCode) { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); String picName = null; if (cameraIntent.resolveActivity(activity.getPackageManager()) != null) { if (BaseConfig.sSDCardExist) { picName = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + Environment.DIRECTORY_DCIM + File.separator + "Camera" + File.separator + activity.getString(R.string.app_name) + "_" + System.currentTimeMillis() + ".jpg"; } else { picName = activity.getCacheDir().getPath() + File.separator + activity.getString(R.string.app_name) + "_" + System.currentTimeMillis() + ".jpg"; } File photoFile = new File(picName); // FileUtils.createFile(photoFile); Uri uri = FileProvider.getUriForFile(activity, App.getInstance().getApplicationId() + ".provider", photoFile); List<ResolveInfo> resInfoList = activity.getPackageManager() .queryIntentActivities(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); activity.startActivityForResult(cameraIntent, requestCode); } else { AppToast.showToast(R.string.open_camera_failure); } return picName; }
Example 6
Source File: LocalFileTask.java From SoBitmap with Apache License 2.0 | 5 votes |
@Override protected List<String> doInBackground(Void... params) { File dir = new File(Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_DCIM + "/Camera"); if (dir.exists()) { List<String> data = new ArrayList<>(); for (File f : dir.listFiles()) { if (f.isFile()) { data.add(f.getAbsolutePath()); } } return data; } return null; }
Example 7
Source File: ImageFileUtil.java From bither-android with Apache License 2.0 | 5 votes |
public static File getImageForGallery(long timeMillis) { String pictureName = getImageNameForGallery(timeMillis); File dcimFile = new File(Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DCIM, "Camera"); if (!dcimFile.exists()) { dcimFile.mkdirs(); } File file = new File(dcimFile, formatFileName(pictureName)); return file; }
Example 8
Source File: ImageUtils.java From Android-Next with Apache License 2.0 | 5 votes |
public static File getMediaDir(String dirName) { File dcim = new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM); File mediaDir = new File(dcim, dirName); if (!mediaDir.exists()) { mediaDir.mkdirs(); } return mediaDir; }
Example 9
Source File: FileUtils.java From LyricHere with Apache License 2.0 | 4 votes |
public static File getDcimFolder() { return new File("/sdcard/" + Environment.DIRECTORY_DCIM); }