使用默认相机应用程序的照片和视频保存在SD卡上。
我真的需要知道是否有一种方法(简单或困难)来改变路径,这样我就可以把这些文件保存在内存中。
或者如果你知道android市场的另一款相机应用程序可以选择改变路径。
我不需要SD卡解决方案。

最佳答案

你可以这样做,
这对我来说很管用。

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
startActivityForResult(intent, TAKE_PHOTO_CODE);

和getImageUri()
/**
 * Get the uri of the captured file
 * @return A Uri which path is the path of an image file, stored on the dcim folder
 */
private Uri getImageUri() {
    // Store image in dcim
    // Here you can change yourinternal storage path to store those images..
    File file = new File(Environment.getExternalStorageDirectory() + "/DCIM", CAPTURE_TITLE);
    Uri imgUri = Uri.fromFile(file);

    return imgUri;
}

有关更多信息,请查看How to capture an image and store it with the native Android Camera
编辑:
在我的代码中,我将图像存储在SDCARD上,但您可以根据需要提供内部存储路径,例如,/data/data/<package_name>/files/
您可以使用Context.getFilesDir()。但请记住,即使是默认情况下,这也是你的应用程序的私有,因此其他应用程序(包括媒体商店)将无法访问它。也就是说,您始终可以选择使文件成为可读或可写的。
也可以使用Context.getDir()来编写其他应用程序可以写入的目录。但是,我再次质疑在本地存储中存储图像数据的必要性。除非用户在使用你的应用程序时没有安装SD卡(这并不常见),否则用户不会感激。

10-08 03:14