cordova-plugin-contacts-phone-numbers
cordova-plugin-contacts-phone-numbers copied to clipboard
cordova.file.externalRootDirectory not working in Android 11 devices
https://stackoverflow.com/q/70110433/3663594
I not able to download file in android 11 version devices.
**Details :**
cordova android 10.1.0
"cordova-plugin-file" version="6.0.2"
"cordova-plugin-file-transfer" version="1.7.1"
"cordova-plugin-filepath" version="1.6.0"
**My Code:**
Below code I written to download files device its working in android 9 and 10 , when I target SDK 30 its not working and failing in only android 11.
window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory, function(dir) {
dir.getFile(filename, {create:true}, function(file) {
file.createWriter(function(fileWriter) {
fileWriter.write(DataBlob);
alert('Message', 'File Downloaded Successfully');
}, function(){
alert('Error!', "Unable to save the file");
});
},function(e){
alert('Error!', e);
});
},function(e){
console.log(e);
});
**I tried with below code in Androidmainfest file**
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACTION_MANAGE_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
**Config.xml file**
<preference name="AndroidInsecureFileModeEnabled" value="true" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
Please let me know if anything is missing , Thank you in advance.