Using a flutter app, I created a db file in 'storage/emulated/0/Documents/Keep/cs.db' path. I deleted the app. I again installed the app and want to delete/copy the file I created. But now I can't do anything to that file. Why?
I have the required permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
I have added android:requestLegacyExternalStorage="true" as well.
I am doing the following thing to delete that file:
File oldBackup = File(destinationPath);
print(await oldBackup.exists());
oldBackup.deleteSync();
print(await File(destinationPath).exists());
await oldBackuo.exists() returns true,
but oldBackup.deleteSync() and oldBackup.delete() returns "PathNotFoundException: Cannot delete file, path = 'storage/emulated/0/Documents/Keep/cs.db' (OS Error: No such file or directory, errno = 2)"
How? How can I delete/copy that file when I 2nd time install the app?
oldBackup.exists()
but before itsFuture
completes for your process's current working directory to change, which could causeoldBackup.deleteSync()
to fail. Does usingoldBackup.existsSync()
make any difference?