for (var i in ids) {
alert("image" + i + ".png");
setTimeout(function () {
(function () {
fs.root.getFile("image" + i + ".png", {
create: true
}, function (fileEntry) {
alert("fileimage" + i + ".png");
console.log(fileEntry);
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = function (e) {
console.log("image successfully written to filesystem.");
};
var blob = new Blob([ids[i]]);
fileWriter.write(blob);
}, errorHandler);
}, errorHandler);
})(i)
}, i * 1000);
}
I am trying to save multiple images to file api. ids array has multiple images as blobs. Here my problem is that, 1st alert ie,"alert("image"+i+".png");" gets triggered 4 times and then only 2nd alert is getting triggered for the first time. How can i make it get triggered one after the other??
Please help, Thanks