Search code examples
androidandroid-10.0android-11android-storagescoped-storage

Migrate folder in /storage/emulated/0/<my_folder> from Android 10 to 11


In my existing app(Android 10) I have a folder under /storage/emulated/0/<my_folder>. After looking to various sources on Google Developers I don't think that it's possible to longer access the /storage/emulated/0/<my_folder> directory under Android 11, because of the changes made in storage access permission.

Of course I can create these folder under Android 11 inside the so called "scoped storage" as mentioned by Google. But if a user updates the app from 10 to 11, how can I access the old folder for copying the files inside to the new folder inside "scoped storage" when I am on Android 11?

Or is there some other way to migrate this folder under /storage/emulated/0/<my_folder> safely?


Solution

  • With intent ACTION_OPEN_DOCUMENT_TREE you can let the user choose your <myfolder>.

    For new installations use /storage/emulated/0/Documents/<my_folder> instead.

    There is no reason to copy files or folders.