I have the following code to unlink/delete a file from the downloads folder I created also through the application using the same path.
Note I am using the RNFetchBlob package.
---
const fs = RNFetchBlob.fs
const base64 = RNFetchBlob.base64
const dirs = RNFetchBlob.fs.dirs
RNFetchBlob.fs
.unlink(dirs.DownloadDir + '/passpoint.config.xml')
.then(() => {
alert("File deleted");
})
.catch(err => {
alert(err);
});
---
I keep getting the following error;
[Error: Failed to delete '/storage/emulated/0/Download/passpoint.config.xml']
I thought it may have been the path but this is the same path I used to create the file and I can see the file via the File Explorer on Android.
Solution
fs.unlink(dirs.DownloadDir + '/passpoint.config.xml');
Just add
android:requestLegacyExternalStorage="true"
in the AndroidManifiest.xml file