confused
confused

Reputation: 761

Android SAF how to acces a file a user moved into my directory that already has persistant permissions

I can see why this might not work, but still feel like it should work. I have a directory, the user has granted me permissions to access it and I have stored those. This all works fine for coming back and requesting files from that directory on subsequent runs of my app. I can access them all in the background.

Now my user drags a new file into that directory. I scan the directory when the user comes back to my app using val directory = DocumentFile.fromTreeUri(appContext, directoryUri) and then I try to open it for processing. But Android throws a security exception that there are no permissable grants for that uri. I checked and at least the uri is pointing to the file in the right directory (not the old one). So of course I can't process the file.

If I restart my app? No problem it finds that file and opens it. If I save a new file myself through my app using SAF, also works no problem.

So is this intended behavior? Did I miss some kind of refresh I'm supposed to do? The user granted me permission to that folder, and then dragged a file in there. I'd expect to be able to get permissions on it.

Upvotes: 0

Views: 13

Answers (0)

Related Questions