如何改变相机的保存路径?路径、相机

2023-09-07 16:15:37 作者:彼岸花谢ㄨ她为君心碎ぺ

照片,并使用默认的摄像头应用程序的视频保存在SD卡上。

Photographs and videos using the default camera app are saved on the SD card.

我真的需要知道,如果有一种方法(易跌难)为更改路径,这样我就可以节省内存的文件

I really need to know if there is a way (easy or hard) to change the path so i can save those files on internal memory.

或者,如果你知道从Android Market其他相机应用程序,有选项可以更改路径。

Or if you know another camera app from android market that has the option to change path.

我不需要SD卡解决方案。

I don't need SD card solutions.

推荐答案

您可以这样做,

这在我的情况。

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

和getImageUri()

And 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捕获图像,并将其与原生的Andr​​oid相机存储

编辑:

在我的code我存储图像的 SD卡,但你可以给内部存储路径,按您的需求,如, /数据/数据/<程序包> /文件/ ..

In my code I store images on SDCARD but you can give Internal storage path as per your need, like, /data/data/<package_name>/files/..

您可以使用 Context.getFilesDir()。但请记住,即使是默认专用于您的应用程序,以便其他应用程序(包括媒体存储)将无法访问它。这就是说,你总是要做出世界上的文件读取或写入的选项。

You can use Context.getFilesDir(). But keep in mind that even that is by default private to your app, so other applications (including the media store) will not be able to access it. That said, you always have the option to make files world read or writeable.

Context.getDir() Context.MODE_WORLD_WRITEABLE 编写其他应用程序可以写入到一个目录。但同样,我怀疑需要存储图像数据中的本地存储。用户不会AP preciate,除非用户预计将不会有他们的SD卡安装在使用你的应用程序(这是不常见)。

also Context.getDir() with Context.MODE_WORLD_WRITEABLE to write a directory that other apps can write into. But again, I question the need to store image data in local storage. Users won't appreciate that, unless users are expected to not have their SD card mounted while using your app (which is not common).