0

When i try to use the example of Ionic API to write or read a File, it doesn´t work but dont crash or throw an error. Callback functions dont works.
Here is the example of the API:

function writeFile(fileEntry, dataObj) {
// Create a FileWriter object for our FileEntry (log.txt).
fileEntry.createWriter(function (fileWriter) {

    fileWriter.onwriteend = function() {
        console.log("Successful file write...");
        readFile(fileEntry);
    };

    fileWriter.onerror = function (e) {
        console.log("Failed file write: " + e.toString());
    };

    // If data object is not passed in,
    // create a new Blob instead.
    if (!dataObj) {
        dataObj = new Blob(['some file data'], { type: 'text/plain' });
    }

    fileWriter.write(dataObj);
});

}

1 Answer 1

1

You must go to Index.html file and put the polifill.js library before cordoba.js library:
<script src="build/polyfills.js"></script>

 <script src="cordova.js"></script>

I do not know why this does not throw any exception, but doing this is solved.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.