npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cordova-plugin-android-openfile

v1.0.33

Published

Open files in local file system. Android 13+ permisions using Storage Access Framework (SAF) and Intents

Readme

cordova-plugin-android-openfile

A Cordova plugin for opening files on Android. Uses MediaStore on Android 10+ and FileProvider on Android 9 and below. Designed for Android 16 scoped storage compliance.

Platform: Android only
Minimum SDK: Android 5.0 (API 21)
npm: https://www.npmjs.com/package/cordova-plugin-android-openfile


Installation

cordova plugin add cordova-plugin-android-openfile

What it does

Provides three methods on cordova.plugins.openFile:

| Method | Description | |--------|-------------| | openDownloadedFile(path, [options], success, error) | Opens a file by its native path | | openPdfUsingSAF(success, error) | Opens the system file picker (SAF) for the user to select a PDF | | requestPermissions(success, error) | Requests storage permissions (Android 9 and below only) |

How files are opened

| Android version | Mechanism | |----------------|-----------| | Android 10+ (API 29+) | File is temporarily copied to Downloads/TechView/ via MediaStore. MediaStore URIs are accessible by any app — no URI grants required. The copy is deleted when the user returns to your app (configurable). | | Android 9 and below (API 28-) | File is served via FileProvider using a content:// URI with explicit URI permission grants. |

The file in cordova.file.externalCacheDirectory is always kept as the download cache — the MediaStore copy is only created at open time.


Usage

Open a downloaded file

The file must already exist on the device. Pass the native file path — no file:// prefix.

var filePath = cordova.file.externalCacheDirectory.replace('file://', '') + 'myfile.pdf';

cordova.plugins.openFile.openDownloadedFile(
    filePath,
    function() {
        console.log('File opened successfully.');
    },
    function(err) {
        console.error('Error opening file:', err);
    }
);

Open with options

An optional options object can be passed as the second argument.

cordova.plugins.openFile.openDownloadedFile(
    filePath,
    { cleanup: true },   // default — deletes the Downloads copy when user returns to app
    function() { console.log('Opened.'); },
    function(err) { console.error(err); }
);
cordova.plugins.openFile.openDownloadedFile(
    filePath,
    { cleanup: false },  // keep the file in Downloads/TechView permanently
    function() { console.log('Opened.'); },
    function(err) { console.error(err); }
);

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | cleanup | boolean | true | When true, the MediaStore copy in Downloads/TechView/ is deleted when the user returns to the app. When false, the file remains in Downloads. Only applies to Android 10+. |

Open the SAF file picker (user selects a PDF)

cordova.plugins.openFile.openPdfUsingSAF(
    function() {
        console.log('PDF opened successfully.');
    },
    function(err) {
        console.error('Error:', err);
    }
);

Request storage permissions (Android 9 and below)

Not required when using externalCacheDirectory on Android 10+.

cordova.plugins.openFile.requestPermissions(
    function() {
        console.log('Permission granted.');
    },
    function(err) {
        console.error('Permission denied:', err);
    }
);

Supported file types

openDownloadedFile detects the MIME type from the file extension so Android presents only compatible apps in the chooser.

| Extension | MIME type | |-----------|-----------| | .pdf | application/pdf | | .doc | application/msword | | .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | | .xls | application/vnd.ms-excel | | .xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | | .jpg / .jpeg | image/jpeg | | .png | image/png | | other | */* |


FileProvider paths (Android 9 and below)

The plugin registers a FileProvider with authority {applicationId}.provider:

<external-path name="external_files" path="." />
<external-cache-path name="external_cache_files" path="." />
<files-path name="internal_files" path="." />
<cache-path name="internal_cache" path="." />

Files must be within one of these paths for FileProvider to serve them.


Android permission requirements

| Android version | Permission needed | |----------------|------------------| | Android 10+ (API 29+) | None — MediaStore is used | | Android 9 and below (API 28-) | READ_EXTERNAL_STORAGE / WRITE_EXTERNAL_STORAGE if accessing shared storage |


License

ISC