Search code examples
ionic-frameworkionic2cordova-plugins

What is the issue of this code?


const fs:string = cordova.file.dataDirectory;
File.writeFile(fs, "a.dat",JSON.stringify(A).{append:true}).then(data=>{
//some code here
});

it works when append = false but it doesn't work when append = true. Please help me


Solution

  • You can do like this.

    const fs:string = cordova.file.dataDirectory;
    File.removeFile(fs,"a.db").then(data1=>{
    File.writeFile(fs, 'a.db', JSON.stringify(A), {append: true}).then(data => {
                                console.log("a.db saved" + JSON.stringify(A));
                            })
                             });