Skip to content Skip to sidebar Skip to footer

Why Since Android 6 I Can't Delete A File Located On A Usb Key With Saf?

I use SAF to access files on a USB key. Since Android 6 it is impossible to delete a file by the delete method of an object FileDocument. Why ?

Solution 1:

Use DocumentFile.html#delete(). If that failed then please post exception or error message.

Also, did you send Intent with ACTION_OPEN_DOCUMENT or ACTION_OPEN_DOCMENT_TREE?

Depending on which action you're using you'll need to request at least Intent.FLAG_GRANT_WRITE_URI_PERMISSION, i.e.:

    intent.addFlags(
        Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
            | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION
            | Intent.FLAG_GRANT_READ_URI_PERMISSION
            | Intent.FLAG_GRANT_WRITE_URI_PERMISSION

Post a Comment for "Why Since Android 6 I Can't Delete A File Located On A Usb Key With Saf?"