Cordova Can’t save files inside root folder

Asked

Viewed 7 times

0

I’m trying to save it in the briefcase Download in the root do dispositivo Android, but do not access it and the file is not created, not even if I create directory.

In the Cordova documentation you ask to use LocalFileSystem.PERSISTENT , but I still can’t access the system root.Even if I type manual the location :file:///storage/emulated/0/,still cannot access and generate any file.

Current code that saves in file:///storage/emulated/0/Android/data/io.ionic/files/

    window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory , function (dir) {
    // dir.getDirectory('images', { create: true }, function (subDirEntry) {});
    dir.getFile(fileName, { create: true, exclusive: false }, function (fileEntry) {
        fileEntry.createWriter(function (writer) {
        writer.onwrite = function (evt) {
            Swal.fire({
            icon: 'success',
            text: `${fileName} foi salvo na pasta ${cordova.file.externalDataDirectory}`,
            showConfirmButton: true
            });
        };
        writer.write(fileData);
        })

    }, function () {
        Swal.fire({
        icon: 'error',
        text: `Houve algum erro ao gerar o pdf , tente novamente`,
        showConfirmButton: true
        });
        });
    });
}

And in itself config.xml preferences to access are set for various folders

<preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />

<preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,assets,root" />

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.