File Manager, other apps unable to access Nextcloud documents
- Dominant language
- Kotlin
- Stars
- 5.6k
- Forks
- 2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 92
Description
### ⚠️ Before posting ⚠️
- [x] This is a **bug**, not a question or an enhancement.
- [x] I've [searched for similar issues](https://github.com/nextcloud/android/issues) and didn't find a duplicate.
- [x] I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
- [x] I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/).
### Steps to reproduce
When trying to open a file in Nextcloud using a file manager:
1. Use an app that supports opening files using a file manager app (such as [KeePassDX](https://github.com/Kunzisoft/KeePassDX) opening a password database file)
2. Find the Nextcloud provider in the hamburger menu
3. Presented with an error (in my case, "Can't load content at the moment")

When trying to open the file using a third party app (KeePassDX) that had a URI at one point:
1. Select file from recently opened list
2. Receive an "Access to the file revoked by the file manager" and "Permission Denial: opening provider androidx.core.content ..."

### Expected behaviour
Files and documents are presented without error
### Actual behaviour
Multiple errors encountered
### Android version
OxygenOS 9.0.16 (Android 9)
### Device brand and model
Oneplus 6T
### Stock or custom OS?
Stock
### Nextcloud android app version
3.34.0
### Nextcloud server version
31.0.9
### Using a reverse proxy?
Yes
### Android logs
```
1761492878.860 10248 30370 30784 D UriUtil : Take read permission content://org.nextcloud.files/external_files/emulated/0/Android/media/com.nextcloud.client/nextcloud/[my NC user]%40[my current, valid NC host]/passwords.kdbx
1761492878.861 10248 30370 30784 E UriUtil : java.lang.SecurityException: No persistable permission grants found for UID 10248 and Uri content://org.nextcloud.files/external_files/emulated/0/Android/media/com.nextcloud.client/nextcloud/[my NC user]@[my current, valid NC host]/passwords.kdbx [user 0]
1761492881.967 10047 27917 30837 W LastAccessedStorage: java.io.FileNotFoundException: Failed to find matching mRoot for Root{authority=org.nextcloud.documents, rootId=[my NC user]@[my old, invalid NC host]/nextcloud, title=Nextcloud, isUsb=false, isSd=false, isMtp=false} @ content://org.nextcloud.documents/root/[my NC user]%40[my old, invalid NC host]%2Fnextcloud
1761492882.051 10047 27917 28223 W Documents: Failed to load org.nextcloud.documents, [my NC user]@[my current, valid NC host]
1761492884.370 10047 27917 28223 W DocumentAccess: Couldn't create DocumentInfo for uri: content://org.nextcloud.documents/document/null
1761492884.391 10047 27917 27917 E GetRootDocumentTask: Cannot find document info for root: Root{authority=org.nextcloud.documents, rootId=[my NC user]@[my current, valid NC host], title=Nextcloud, isUsb=false, isSd=false, isMtp=false} @ content://org.nextcloud.documents/root/[my NC user]%40[my current, valid NC host]
```
Note: Interestingly, both my current NC server host and my old, invalid host show up in these log entries. Some time ago I migrated my data to a docker container and changed the hostname along with it. I cleared out my old account info in the Nextcloud app and added the new account info. My third-party app has been using files from the new host.
### Server error logs
```bash
```
### Additional information
- https://github.com/nextcloud/android/issues/9906
- Almost exactly like this issue, although a fix was apparently released that subsequently closed the issue. Must be different than what I'm experiencing now.
- https://github.com/nextcloud/android/issues/10249
- Less relevant - Nextcloud does still show as an option in the file manager.
Contributor guide
Assessment
This issue has not been assessed yet.