I have a small XML data file containing some licensing information that I would like to leave on the device even after the app is uninstalled. Is there a way to do it with Android 11?
It appears due to Scoped Storage, I am limited to storing data to a designated app folder in external or internal storage. And in each case, the data is deleted when the app is deleted.
Is it even possible to persist a file on Android 11?
If the file already exists and not trying to create the file at the time of being uninstalled your options are limited and not really good.
There is no way to keep a file around without user interaction. Your only option is really to use the Storage Access Framework to save the file. What happens here is you have to have the user pick where they want to save the file via file picker intent. Get the uri path in onActivityResult
and use that to save the file.
Aside from requiring user intervention this also puts your file that has the licensing information in a publicly accessible location where anyone can get it which might not be something you want
That's really your only option if you want to keep a file around after your app has been uninstalled.