gpt4 book ai didi

java - 如何更改相机保存路径?

转载 作者:太空狗 更新时间:2023-10-29 16:23:28 29 4
gpt4 key购买 nike

使用默认相机应用程序拍摄的照片和视频保存在 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() .但请记住,默认情况下即使是您的应用程序也是私有(private)的,因此其他应用程序(包括媒体商店)将无法访问它。也就是说,您始终可以选择将文件设置为可读或可写。

还有Context.getDir()Context.MODE_WORLD_WRITEABLE编写其他应用程序可以写入的目录。但我再次质疑将图像数据存储在本地存储中的必要性。用户不会喜欢这一点,除非用户在使用您的应用时不希望安装他们的 SD 卡(这并不常见)。

关于java - 如何更改相机保存路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8519688/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com