Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cordova.file.externalRootDirectory not working in Android 11 devices #66

Open
Maheshvy opened this issue Nov 25, 2021 · 0 comments
Open

Comments

@Maheshvy
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant