0

In my Android app, the user can select a folder thanks to Intent.ACTION_OPEN_DOCUMENT_TREE I can then write files to this folder.

The problem is that the user can delete this folder or remove the permission to access it.

In both cases, I would like to display a message to explain the user what is happening and how to fix this issue.

I need 2 different messages and so I need to differentiate these 2 cases

I wanted to use DocumentFile.exists() but it returns false in both cases.

How can I do that?

Laurent D.
  • 449
  • 4
  • 19
  • 1
    How can a user remove an access permission? – blackapps Jan 28 '23 at 22:14
  • @blackapps, In Settings->Apps->your app->Storage, you can see the number of items you granted. There is also a 'clear access" button to remove these items. – Laurent D. Jan 29 '23 at 07:20
  • An on new Android version, you you don't use an app for some time, Android may automatically remove all accesses. – Laurent D. Jan 29 '23 at 07:21
  • Sorry, but i have never seen that a user can revoke there permanent directory permissions obtained with ACTION_OPEN_DOCUMENT_TREE. You are pretty mistaken and confusing. – blackapps Jan 29 '23 at 08:30
  • Android can automatically remove a storage, camera, location,... permission yes. But will never remove one obtained by SAF like with ACTION_OPEN_DOCUMENT_TREE. You are pretty confusing. – blackapps Jan 29 '23 at 08:41
  • @blackapps, you are right about permissions obtained by SAF. Sorry to be confusing, but Android doesn't make new features easy to learn. However, the problem stays the same as the user can manually removed these permissions. – Laurent D. Jan 29 '23 at 12:19
  • ??? No. The user can not. Strange.. first you agree and then you deny. Confusing, confusing. – blackapps Jan 29 '23 at 12:24
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/251470/discussion-between-laurent-d-and-blackapps). – Laurent D. Jan 29 '23 at 12:27

0 Answers0