Home > Blockchain >  Should I release persistableUriPermission when a new storage location is chosen
Should I release persistableUriPermission when a new storage location is chosen

Time:02-14

I let my user select the directory, where to store the file output of my app, using the ACTION_OPEN_DOCUMENT_TREE Intent. When the user has selected a directory, I am persisting the uri permissions (contentResolver.takePersistableUriPermission), so I can use this directory without further bothering the user.

The user is later on allowed to change that directory, so that the location, where my app is storing the files changes. Should I release the uri permissions for the previously used directory? What are the consequences of not caring about that?

CodePudding user response:

What are the consequences of not caring about that?

There is a limit of how many persistable permissions your app can hold. For a long time, it was 128. Android 11 raised it to 512, and it seems to be 512 for Android 12 as well.

Should I release the uri permissions for the previously used directory?

Ideally, yes, just so you do not wind up with a "leak" of those grants and cause yourself problems in the future.

  • Related