我的要求是从Android中的相机拍摄照片,而不是将照片保存在文件中,而是将其保存在存储器中,因此文件不是被留下来。如何在Android中拍照但将其保存在内存中
我知道一个选择是之后删除文件,但这还不够好,我需要另一个级别的安全性,所以根本没有留下任何痕迹。以下代码来自“简单拍照”,为简洁起见,我缩短了代码。
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// **Create the File** where the photo should go
File photoFile = createImageFile();
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(...,...,photoFile);
takePictureIntent.putExtra(..., photoURI);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
String mCurrentPhotoPath;
private File createImageFile() throws IOException {
// Create an **image file** name
return image;
}
这里的要点是需要一个“文件”,我需要删除它。到目前为止,我的研究使我创建了自己的ContentProvider,像这样https://gist.github.com/m039/6550133“Custom ContentProvider”,基于内存数组(android)。我希望得到比这更简单的解决方案。任何其他想法将不胜感激,谢谢。
将文件存储在SD卡中,然后在使用后删除文件。 –