open failed: ENOENT (No such file or directory)
Already added manifests, Because Environment.getExternalStorageDirectory() is deprecated on Android R.if I change that to getExternalFilesDir() the path is going to the app directory, not to storage
android:requestLegacyExternalStorage="true"
Android Q Below working fine but Android R got the ENOENT error
protected Uri getImageFile()
{
String imagePathStr = IMAGE_FOLDER;
File path = new File(imagePathStr);
if (!path.exists()) {
path.mkdirs();
}
String finalPhotoName = "IMG" +
(withTimeStamp ? "_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date(System.currentTimeMillis())) : "")
+ ".png";
// long currentTimeMillis = System.currentTimeMillis();
// String photoName = imageName + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date(currentTimeMillis)) + ".jpg";
File photo = new File(path, finalPhotoName);
return Uri.fromFile(photo);
}
what is the string of the IMAGE_FOLDER
try to use
getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)