Somehow I keep getting the βerror code 5β when trying to set the next right. What I want to do is copy the existing file from the assets in android to an accessible place on the Android device in order to be able to share it through other applications (for example, mail).
Here is my sample code:
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; var storagefolder = cordova.file.dataDirectory; var storagefolderpointer; console.log("storage folder: " + storagefolder); // Check for support. if (window.requestFileSystem) { console.log("filesystem beschikbaar"); var getFSfail = function () { console.log('Could not open filesystem'); }; var getFSsuccess = function(fs) { var getDIRsuccess = function (dir) { console.debug('Got dirhandle'); cachedir = dir; fileurl = fs.root.fullPath + '/' + storagefolder; storagefolderpointer = dir; }; var getDIRfail = function () { console.log('Could not open directory'); }; console.debug('Got fshandle'); FS = fs; FS.root.getDirectory(storagefolder, {create:true,exclusive:false}, getDIRsuccess, getDIRfail); }; window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, getFSsuccess, getFSfail); setTimeout(function() { console.log("directory beschikbaar"); var suc = function(entry){ var goe = function(){ console.log("copy success"); }; var fou = function(){ console.log("copy NOT NOT success"); }; entry.copyTo(storagefolder, "vcard.vcf", goe, fou); }; var fai = function(e){ console.log("fail getFile: " + e.code); }; window.resolveLocalFileSystemURL(storagefolderpointer + "www/visitekaart/vcard.vcf", suc, fai); }, 1000); } else { console.log("filesystem NOT NOT NOT available"); }
source share