I need to execute
window.resolveLocalFileSystemURI(file,success,fail)
within a for
loop where different file entries are passed. The goal is to only return the resolved entries in an array once all entries have been successfully retrieved.
function resolveFiles(result,callback)
{
var resultData=[];
window.resolveLocalFileSystemURI(result, function(entry)
{
resolvedGalleryImages.push(entry);
callback(resolvedGalleryImages);
resolvedGalleryImages=[];
}, function(e)
{
alert("err"+e);});
}
//calling--
//@filesarr contains URIs of captured images
for(i = 0; i < filesarr.length; i++)
{
resolveFiles(filesarr[i],function(result){
var resultArr = result;
});
}
What steps can I take to ensure that the callback is not triggered before all entries have been obtained?