Skip to content Skip to sidebar Skip to footer

Phonegap Open File In Native App. Build Via Build.phonegap.com

At first: YES, there are many solutions in StackOverflow, but non of them works in my case. I got application built in SmartGWT.mobile I attached config files and all needed files

Solution 1:

don's FileOpener version have worked on my app cordova 3.0

phonegap local plugin add https://github.com/don/FileOpener

all the xmls, plugin, etc are then added automatically.

added fileopener.js on index.html and then

window.plugins.fileOpener.open( path );

Solution 2:

$("#page").on('pageshow', function(event, ui) {
 if(event.handled !== true)
    {
    window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
    event.handled = true;
    }
  returnfalse;
});

functionfail() {
    console.log("failed to get filesystem");
}

functiongotFS(fileSystem) {
   console.log("got filesystem");

   // save the file system for later accessconsole.log(fileSystem.root.fullPath);
   window.rootFS = fileSystem.root;
    downloadImage(url, fileName);
}

functiondownloadImage(url, fileName){
   var ft = newFileTransfer();
   ft.download(
    url,
    window.rootFS.fullPath + "/" + fileName,
    function(entry) {
        console.log("download complete: " + entry.fullPath);           
    },
    function(error) {
            console.log("download error" + error.code);
    }
 );
}

Post a Comment for "Phonegap Open File In Native App. Build Via Build.phonegap.com"