如何将拍摄的照片保存在Android的应用程序目录中 [英] How to save captured photo in application directory in Android
本文介绍了如何将拍摄的照片保存在Android的应用程序目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我想将捕获的照片保存在 SQLite
等所在的应用程序目录中.我不想在 SD 卡中创建任何文件夹和任何隐藏文件.如何将捕获的照片保存在应用程序目录中.
Hello I want to save captured photo in application directory where SQLite
etc reside. I don't want to make any folder and any hidden file in the SD Card. How this can be save the captured photo in application directory.
我在下面尝试这个,但它保存在隐藏文件的 SD 卡中,但我不想要这种方法.
I am trying this below but it is saving in the SD card that is hidden file but I don't want this approach.
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
String capturedPhotoName = "." + System.currentTimeMillis() + ".png";
File photo = new File(Environment.getExternalStorageDirectory(),
capturedPhotoName);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
startActivityForResult(cameraIntent, CAMERA_INTENT_REQUEST);
提前致谢!
推荐答案
试试这个方法将捕获的图像保存在应用程序存储中
Try this method to save captured image in application storage
public Uri setImageUri() {
ContextWrapper cw = new ContextWrapper(getApplicationContext());
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
File file = new File(directory,System.currentTimeMillis() + ".png");
Uri imgUri = Uri.fromFile(file);
this.imgPath = file.getAbsolutePath();
return imgUri;
}
图像将存储在此位置
/data/data/com.your.packagename/app_data/imageDir
这篇关于如何将拍摄的照片保存在Android的应用程序目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文