如何在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);
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;
}