Before founding this post I create my own function that do this, trying to get a filesystem with a determined bytes until reach the limit and assume the free space, recursively. Due the callbacks, maybe it's necessary set a timeout bigger than 0. In my tests, the diference between the cordova.exec way and my way was very small, and is possible better the accuracy lowering the value of the limit.
function availableBytes(callback, start, end){
callback = callback == null ? function(){} : callback
start = start == null ? 0 : start
end = end == null ? 1 * 1024 * 1024 * 1024 * 1024 : end //starting with 1 TB
limit = 1024 // precision of 1kb
start_temp = start
end_temp = end
callback_temp = callback
if (end - start < limit)
callback(start)
else{
window.requestFileSystem(LocalFileSystem.PERSISTENT, parseInt(end_temp - ((end_temp - start_temp) / 2)), function(fileSystem){
setTimeout(function(){
availableBytes(callback_temp, parseInt(parseInt(end_temp - ((end_temp - start_temp) / 2))), end_temp)
}, 0)
}, function(){
setTimeout(function(){
availableBytes(callback_temp, start_temp, parseInt(end_temp - ((end_temp - start_temp) / 2)))
}, 0)
})
}
}
Can be used like:
availableBytes(function(free_bytes){
alert(free_bytes)
}