如何在Android中的自定义文件夹中保存录制的视频

时间:2013-03-04 12:12:47

标签: android video-recording

如何将视频保存在自定义文件夹中,而不是默认文件夹中,因此这是我的代码,但是当我关闭录制时它只是挂起

        File dir = new File(Environment.getExternalStorageDirectory()+ "/FutureCopyright");
            if (dir.exists() && dir.isDirectory()) {
                // do something here
            } else {
                // create dir here
                dir.mkdir();
            }
            System.out.println(1);
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
            System.out.println(2);
            cameraIntent.putExtra(android.provider.MediaStore.Video.Media.MIME_TYPE,"video/3gp");
            System.out.println(3);
            cameraIntent.putExtra(android.provider.MediaStore.EXTRA_DURATION_LIMIT,6000);
            System.out.println(4);
            ff=new File(SDCARD_ROOT_PATH + SAVE_PATH_IN_SDCARD,VIDEO_CAPTURE_NAME);
            System.out.println(5);
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile((ff)));
            System.out.println(6);
            startActivityForResult(cameraIntent,SELECT_PICTURE);

1 个答案:

答案 0 :(得分:0)

这样做。为了保存文件,你可以参考这个链接。

 public boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
    return true;
}
return false;
}
public boolean isExternalStorageReadable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state) ||
    Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
    return true;
}
return false;

}

  

http://developer.android.com/training/basics/data-storage/files.html