如何保存图像摄像头在特定的文件夹捕获 [英] How to save image captured with camera in specific folder

查看:146
本文介绍了如何保存图像摄像头在特定的文件夹捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想保存的照片和喜欢

Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
String pathMedia = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyImages/image_001.png";
Uri uriSavedImage = Uri.fromFile(new File(pathMedia));
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);

,但它不工作(我穿过onResult,一切都OK),但没有文件夹MyImages。如何强制手机将图像保存到特定的文件夹(它需要与升级Froyo或上工作的每一个型号的手机)? 我加了体现WRITE_EXTERNAL存储和摄像机的权限。

but it doesn't work ( I pass through onResult and everything is Ok ) but there is no folder MyImages. How to force phone to save images to specific folder ( it needs to work on every model phone with Froyo or upper) ? I added to manifest WRITE_EXTERNAL STORAGE and CAMERA privileges.

推荐答案

这可能是因为你从来没有创建的文件夹,试试这个:

It's probably because you never created the folder, try this:

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

这篇关于如何保存图像摄像头在特定的文件夹捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆