Go to file
meddlesome 913bd577d9 Update FileOpener2.java
adding option to showing chooser when open the file
2014-09-08 02:49:56 +07:00
src Update FileOpener2.java 2014-09-08 02:49:56 +07:00
www Initial commit 2014-02-10 12:42:31 +01:00
.gitignore Initial commit 2014-02-10 12:42:31 +01:00
LICENSE Initial commit 2014-02-10 12:42:31 +01:00
plugin.xml - Andorid: Support for both relative and absolute path 2014-06-18 14:14:04 +02:00
README.md Update README.md 2014-05-18 14:11:51 +02:00

A File Opener Plugin for Cordova

This plugin will open a file on your device file system with its default application.

Requirements

  • Android 4+ / iOS 6+
  • Cordova 3.0 or higher

Installation

cordova plugin add [url-of-the-git-repo]

Usage

Open an APK install dialog:

<script>
    cordova.plugins.fileOpener2.open(
        '/sdcard/Download/gmail.apk', 
        'application/vnd.android.package-archive'
    );
</script>

Open a PDF document with the default PDF reader and optional callback object:

<script>
    cordova.plugins.fileOpener2.open(
	    '/sdcard/Download/starwars.pdf', 
	    'application/pdf', 
	    { 
		    error : function(errorObj) { 
			    alert('Error status: ' + errorObj.status + ' - Error message: ' + errorObj.message); 
		    },
		    success : function () {
			    alert('file opened successfully'); 				
		    }
	    }
    );
</script>

Notes

  • For properly opening a PDF file, you must already have a PDF reader (Acrobat Reader, Foxit Mobile PDF, etc. ) installed on your mobile device. Otherwise this will not work

  • It is reported that in iOS, you might need to remove <preference name="iosPersistentFileLocation" value="Library" /> from your config.xml