Actually i want to overwrite the file in local storage of phone but it gives me the error
I/flutter ( 3835): /storage/emulated/0/Android/data/com.example.temp/files/flutter_audio_recorder_
I/flutter ( 3835): Exception: A file already exists at the path :/storage/emulated/0/Android/data/com.example.temp/files/flutter_audio_recorder_.wav
so how can i delete this file first ?
i have stored the wav file path in this variable ==> var dirPath ;
Create this method:
Future<void> deleteFile(File file) async {
try {
if (await file.exists()) {
await file.delete();
}
} catch (e) {
// Error in getting access to the file.
}
}
Usage:
deleteFile(File('your_file_path'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With