Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
My ideas app does not have an online back-end, so users can export a zip file to backup/transport their ideas. Then on their other (new) device, they could import the zip file from their download folder. Inside the app the zip file is extracted and the content (text, audio, images) recreated.
Since Android 10 (and beyond) the way files and permission works is different.
On
https://developer.android.com/training/data-storage/shared/documents-files#grant-access-directory
it says:
When using ACTION_OPEN_DOCUMENT_TREE, your app gains access only to the files in the directory that the user selects.
On Android 11 (API level 30) and higher, you cannot use the ACTION_OPEN_DOCUMENT_TREE intent action to request access to [...] the Download directory.
https://developer.android.com/about/versions/10/privacy/changes
By default, apps targeting Android 10 and higher are given scoped access into external storage, or scoped storage. Such apps can see the following types of files within an external storage device without needing to request any storage-related user permissions:
Files in the app-specific directory, accessed using getExternalFilesDir().
https://developer.android.com/about/versions/11/privacy/storage
(as far as I can tell, the same rules as for 10 regarding my issue)
Since my files are not media files, it doesn't seem to be possible to let users select the file from a list.
I actually thought my current solution (file chooser, pointing to
Environment.getExternalStorageDirectory()
) was working, since it worked in emulator. But today I got a new device with Android 10 and it failed.
I find it very hard to find an answer to this question, because the search words and documentation all resolve around media files (images mostly).
Any way the user could import the zip file will do. But it is quite difficult for a normal user to move a downloaded / USB transfered file first into an app specific folders or something like that.
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.