File is not getting deleted in Android Java?

86 Views Asked by At

File is not getting deleted in Android, I have checked all premissions, and I tried all the solutions available in the internet but nothing helps. Your help will be highly assist me. Thanks in advance.

I used the below permissions

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

And this is the code I used

File dir = Environment.getExternalStorageDirectory();
String path = dir.getAbsolutePath() + "/Recordings/Call/" + filename;
File fdelete = new File(path);
    if (fdelete.exists()) {
      if (fdelete.delete()) {
        System.out.println("file Deleted :" + path);
      } else {                                              
        System.out.println("file not Deleted :" + path);
      }
 }

And the err log is

W/soft.my_app_name: Got a deoptimization request on un-deoptimizable method void libcore.io.Linux.remove(java.lang.String)

enter image description here

Error log is

enter image description here

0

There are 0 best solutions below