I have some codes like this for saving image to gallery,
But it says deprecated for "getExternalStoragePublicDirectory"
I know i need to use MediaStore or getExternalFilesDir or something
But don't know how to
Thanks
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
// Save a file: path for use with ACTION_VIEW intents
currentPhotoPath = image.getAbsolutePath();
return image;
}
question from:
https://stackoverflow.com/questions/65932432/how-can-i-save-captured-image-to-gallery 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…