I believe the file deletion and creation in your code snippet are mixed up. The steps for replacing a file should be as follows:
- Get directory (success/fail);
- Get file (success/fail);
- Delete file (success/fail);
- Create file (success/fail).
I reworked your code like this:
// You should get the directory or create it if it doesn't exist
// and on success call the gotDirEntry fucntion.
}, gotDirEntry, fail);
// You do not need to create the file as it should already exist in the system.
// You should only get the file and on success call the deleteFile function.
// On fail you should directly create the new file.
}, deleteFile, CreateDirEntry);
// First we delete the file and on success we call the CreateDirEntry function.
// Finally you need to create the new file again in the according dir.
}, success, fail);
Further, you can check the Cordova File Api documentation
where you will find more information and some good usage examples about the api.
I hope this helps.
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.