Java Code Examples for android.os.Environment.DIRECTORY_DCIM

The following are Jave code examples for showing how to use DIRECTORY_DCIM of the android.os.Environment class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ScreenRecordCaptureMaster   File: RecordScreenDialog.java   View Source Code Vote up 6 votes
private void initData() {
    File parent = new File(TextUtils.isEmpty(mFilePath) ? Environment.getExternalStorageDirectory() + File.separator
            + Environment.DIRECTORY_DCIM + File.separator + "weibo" : mFilePath);
    if (!parent.exists()) {
        parent.mkdirs();
    }

    mFile = new File(parent.getAbsolutePath() + File.separator + "weibo" + new Date().getTime()
            + ".mp4");
    mTotalController = TotalController.getInstance();
    mTotalController.initEncodeThread();
    setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            return true;
        }
    });
}
 
Example 2
Project: Simpler   File: FileUtils.java   View Source Code Vote up 6 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 3
Project: ScreenRecordCaptureMaster   File: YZBRecordScreenDialog.java   View Source Code Vote up 5 votes
private void initFile() {
    File parent = new File(TextUtils.isEmpty(mFilePath) ? Environment.getExternalStorageDirectory() + File.separator
            + Environment.DIRECTORY_DCIM + File.separator + "weibo" : mFilePath);
    if (!parent.exists()) {
        parent.mkdirs();
    }

    mFile = new File(parent.getAbsolutePath() + File.separator + "weibo" + new Date().getTime()
            + ".mp4");
}
 
Example 4
Project: Simpler   File: CommonUtils.java   View Source Code Vote up 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 5
Project: QMark   File: App.java   View Source Code Vote up 4 votes
public static String getPicturesSaveDir() {
	return FStoreLoc.BIGFILE.getCustomDirCreatableSdCard(get()).path + File.separator + Environment.DIRECTORY_DCIM + File.separator + Const.APP_DIR_NAME;
}