2 myc 100 myc_100 于 2013.04.19 16:40 提问

在sd card中保存 image, audio和 video

如何在sd card中保存文件,在camera 类中创建了一个图片,然后创建一个新的目录来保存它。它创建了文件夹,但这个图片为什么不在文件夹中?

if (items[which].equals("Picture")) {

                            Intent cameraIntent = new Intent(
                                    MediaStore.ACTION_IMAGE_CAPTURE);
                            startActivityForResult(cameraIntent,
                                    PICTURE_ACTIVITY);

                            File imagesFolder = new File(Environment
                                    .getExternalStorageDirectory(),
                                    "SeccyPhotos");
                            imagesFolder.mkdirs(); // <----
                            File image = new File(imagesFolder, "image_001.jpg");
                            Uri uriSavedImage = Uri.fromFile(image);
                            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                                    uriSavedImage);
                        }

我调用了camera类,这样的话之后拍摄的照片就应该保存在文件夹中。
请问下:视频和照相机相同吗?

Intent cameraIntent = new Intent(
                                MediaStore.ACTION_VIDEO_CAPTURE);
                        startActivityForResult(cameraIntent,
                                PICTURE_ACTIVITY);

                        File videosFolder = new File(Environment
                                .getExternalStorageDirectory(),
                                "cangryVideos");
                        videosFolder.mkdirs(); // <----
                        File video = new File(videosFolder, "Video_001.3gp");
                        Uri uriSavedvideo = Uri.fromFile(video);
                        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                                uriSavedvideo);
                        startActivityForResult(cameraIntent,
                                PICTURE_ACTIVITY);

1个回答

luhuajcdd
luhuajcdd   2013.04.19 22:52
已采纳

http://developer.android.com/training/camera/photobasics.html

File f = null;

            try {
                f = setUpPhotoFile(); //setUpPhotoFile() 产生一个文件
                mCurrentPhotoPath = f.getAbsolutePath();
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
            } catch (IOException e) {
                e.printStackTrace();
                f = null;

            }
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!