I'm using the File component to copy a file named a.csv to the Shared scope in the Documents folder.
The first time it copies correctly as a.csv.
But when I try to copy the file again, it doesn't overwrite the existing file — instead, it creates a new file named a.csv (1).
I tried using the File.Delete block before copying, but it doesn’t actually delete the file from the Documents folder.
My goal is to overwrite or replace the existing a.csv file in the Documents folder, not create duplicates like a.csv (1).
Is there a proper way to delete files in Shared scope?
What’s the correct method to ensure overwrite works?
Any suggestions or example blocks would be very helpful!
do I need to prompt the user to select the file via SAF every time I want to delete or overwrite it? Or is there a way to programmatically access and manage that specific file (using its URI or other means) after the initial selection?
My goal is to reliably overwrite or replace the file in the Documents folder without user interaction on every operation.
Permission Denial: writing com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/document/primary%3ADocuments%2Fmath.csv from pid=16564, uid=10415 requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission()
If the CSV file is created (copied) by your app in/to /Documents you can of course delete it with the File component without any storage permissions on Android 11+. If the CSV file is already created by the Companion app, you cannot delete/overwrite it with the compiled app, because this is another app. So delete it before testing with Companion and APK.
At first, the file is saved without any issue, but after a few clicks, it shows an error: "Cannot delete file at Documents/math.csv." As a result, new files are created with names like math.csv (1), math.csv (2), and so on. and also asking for permission.