Search code examples
androidsaveandroid-11android-storagescoped-storage

How can I persist a file in android 11?


I want to persist a file even after uninstalling my app in android 11 . Thanks to android 10 and 11 update about the storage I'm not able to do that any more . Also I don't want to use Data backup or a remote server .It has to be offline. any suggestion ?


Solution

  • You can write the file in the normal way in the Documents folder.

    After reinstallation use ACTION_OPEN_DOCUMENT to let the user choose the file.

    For an Android Q/10 device request legacy external storage in manifest file and you can continue as before 10.