We are implementing a backup/restore system for the app. We used Google Drive API as documented in the Android Guide
We also store image URIs in the database. In the restoring process, we get URIs but lost permission to reach images when we re-install the app. We have the following exception.
Failed query: java.lang.SecurityException: Permission Denial: opening provider ... requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
We get image URI via "ACTION_OPEN_DOCUMENT" but can't persist it after deleting/install the application. What are the related APIs? Do we need to move images in an app-specific folder and backup images itself also?
Thank you for reading this, any help is appreciated
What are the related APIs?
ACTION_OPEN_DOCUMENT_TREE
and ACTION_CREATE_DOCUMENT
are probably what they are referring to.
Do we need to move images in an app-specific folder and backup images itself also?
We cannot really answer that — that is a business decision as much as a technical one. However, if your app is uninstalled and reinstalled:
Uri
values that you obtained from the Storage Access FrameworkHow you work around that is up to you. In addition to your proposal, you could:
ACTION_OPEN_DOCUMENT_TREE
), store relative paths in your database, and request access to that tree again after your app is restoredUri
values from the database before backing it up and live without access to those images if the database is restored