FilePlugin

PhoneGap File Plugin
shahidj1.0.21
platforms: android
$ cordova plugin add com.surfernetwork.fileplugin

FIlePlugin

This plugin will download and copy file from a url to the app directory and read it as well. In case it doesn't find the file from a url it can also copy an alternate default file from the app resources.

Install

Assuming PhoneGap CLI is installed, from the command line.

phonegap local plugin add https://github.com/shahidj/FIlePlugin

PhoneGap Build

Add the following xml to your config.xml to always use the latest version of this plugin:

<gap:plugin name="com.surfernetwork.fileplugin" />

or to use an specific version:

<gap:plugin name="com.surfernetwork.fileplugin" version="1.0.2" />

More informations can be found here https://build.phonegap.com/plugins/413 .

How to Use

It supports Phonegap 3.0 and above

This plugin will retun the file contents in string format after downloading and coping on to device.

From index.js you may call plugin by passing parameters.

    var returnSuccess='success';
    var SettingsFileName='abc.xml';
    var SettingsDownloadUrl='http://example.com/downloads/abc.xml';
var base='http://example.com/downloads/';
    or 
    var base='www/xml/';
    var success = function(result) { 
                console.log("SUCCESS: \r\n"+result );    
            };

    var error = function(error) { 
                      console.error("ERROR: \r\n"+error ); 
                };
   FilePlugin.callNativeFunction( success, error,{'result':returnSuccess,'file':SettingsFileName,'downloadurl':SettingsDownloadUrl,'base_path':base} );