1. Are you ready for the Galaxy S20? Here is everything we know so far!

Cannot delete a file in Android 11

Discussion in 'Android Development' started by robertanisoiu, Aug 2, 2021.

  1. robertanisoiu

    robertanisoiu Lurker
    Thread Starter

    Hello,
    `
    I have an application that make photos into a subdirectory called "DesPictures" in Environment.DIRECTORY_DCIM public directory

    Another application scan the "DesPictures" directory and delete the photos one by one.

    In Android 10 the code is:
    dir = new File (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + "/DesPictures");
    File list[] = dir.listFiles();
    if (list(i) != null) {
    for (int i = 0; i < list.length; i++) {
    list(i).delete(); //WORKS IN Android 10 but DOES NOT WORK IN Android 11
    }
    }

    Can anybody help me, please, in order to delete each list in Android 11? Thank you
     



    1. Download the Forums for Android™ app!


      Download

       
  2. robertanisoiu

    robertanisoiu Lurker
    Thread Starter

    list(i).delete(); //WORKS IN Android 10 but DOES NOT WORK IN Android 11 // cannot write here with right parenthesis
     
Loading...
Similar Threads - Cannot delete file
  1. unet
    Replies:
    0
    Views:
    206
  2. DridriLaBastos
    Replies:
    0
    Views:
    207
  3. kgash
    Replies:
    6
    Views:
    416
  4. ixoni
    Replies:
    8
    Views:
    702
  5. oneytlam
    Replies:
    2
    Views:
    543
  6. Christopher Clayton
    Replies:
    0
    Views:
    368
  7. etijskens
    Replies:
    3
    Views:
    517
  8. Provasek
    Replies:
    5
    Views:
    601
  9. RVDowning
    Replies:
    7
    Views:
    1,234
  10. thaKing
    Replies:
    4
    Views:
    1,644

Share This Page

Loading...