Open SteinerOk opened 2 years ago
Let me give a try to reproduce the issue. I might escalate the problem with the Android storage engineers if it's not related to ModernStorage
So I investigated a bit but wasn't able to reproduce the same issue you're getting (at least on an emulator).
Two things to note though, your getExternalStorageDir
is pointing to two different folders. The first one is the app's own Download external folder (which isn't visible by other apps since Android 11, was never supposed to be public to be honest) and the second one is the shared Download folder (visible with a file manager):
# applicationContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
/storage/emulated/0/Android/data/com.google.modernstorage.storage.test/files/Download
# Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
/storage/emulated/0/Download
On Android 11 (I haven't tried yet on previous versions), it doesn't let me write to the app's own Download external folder. It doesn't trigger an exception but change the target folder by putting it in the device shared Download folder. I've tried setting the same file name but end up having MediaStore adding a suffix automatically:
# First try
uri = content://media/external/file/65
path = /storage/emulated/0/Download/samefile.pdf
# Second try
uri = content://media/external/file/66
path = /storage/emulated/0/Download/samefile (1).pdf
Could you share me a snippet adding the same file twice from your project just to make sure I'm reproducing it in the same way? Thanks!
Describe the bug
I'm using modernstorage to save a file from the web to my Downloads folder. In certain situations, the following error occurs:
To Reproduce
As I managed to find out, this happens if you download a file in the application, then clear the application data and try to download the same file again.
Environment:
Additional context
Some peaces of code, witch I use: