How to keep app’s storage data persist even after uninstalling app in Android 10 (API 29)

  android, android-10.0, android-storage

Since getExternalStorageDirectory() is deprecated on Android 10 (API 29), I’m using context.getExternalFilesDir() for storing downloaded files in internal storage by granting Manifest.permission.WRITE_EXTERNAL_STORAGE, but as per documentation:

This is like getFilesDir() in that these files will be deleted when the application is uninstalled

I am not targeting SAF, as I don’t want to let user chooses the directory with ACTION_OPEN_DOCUMENT_TREE.

Appreciate your help in advance.

Source: Android Questions