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-env

v1.1.0

Published

Cordova Environment plugin

Downloads

38

Readme

cordova-plugin-env

| Download Activity | Travis CI | Snyk | |:-:|:-:|:-:| | npm | Build Status | Known Vulnerabilities |

A small Cordova plugin that exposes Android's Environment object directories.

This plugin defines a global Environment object, which provides access to the common directories available on Android's Environment object. The Environment object is available from the navigator object after the deviceready event fires.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(navigator.Env);
}

Installation

From the Command line:

cordova plugin add cordova-plugin-env

Config.xml for PhoneGap Build:

<gap:plugin name="cordova-plugin-env" source="npm" />

These commands will install the plugin from npm. You can find this plugin up on npm here, or by searching for ecosystem:cordova in the npm registry like this.

Supported Platform

  • Android

Env

The Env object provides a way to access the directories exposed by the Environment object.

Methods

Currently this plugin provides Four methods:

  • getExternalStorageState
  • isExternalStorageEmulated
  • isExternalStorageRemovable
  • getDirectory

getExternalStorageState

Parameters:

  • successCallback: Callback that returns the string value of the External Storage State. See https://developer.android.com/reference/android/os/Environment.html#getExternalStorageState() for possible result values.
  • errorCallback: Callback that executes if an error occurs during the call.

Example

if (navigator.Env) {
    console.log("Env object in navigator");
    navigator.Env.getExternalStorageState(
        function (state) {
            if (state) {
                console.log("External storage state: " + state);
            }
        },
        function (error) {
            console.log("getExternalStorageState error: " + error);
        }
    );
} else {
    console.log("Plugin error: Env plugin not found (is it installed?)");
}

isExternalStorageEmulated

Parameters:

  • successCallback: Callback that returns "true" if the external storage is emulated.
  • errorCallback: Callback that executes if an error occurs during the call.

Example

if (navigator.Env) {
    console.log("Env object in navigator");
    navigator.Env.isExternalStorageEmulated(
        function (result) {
            if (result) {
                console.log("isExternalStorageEmulated returns: " + result);
            }
        },
        function (error) {
            console.log("isExternalStorageEmulated error: " + error);
        }
    );
} else {
    console.log("Plugin error: Env plugin not found (is it installed?)");
}

isExternalStorageRemovable

Parameters:

  • successCallback: Callback that returns "true" if the external storage is removable.
  • errorCallback: Callback that executes if an error occurs during the call.

Example

if (navigator.Env) {
    console.log("Env object in navigator");
    navigator.Env.isExternalStorageRemovable(
        function (result) {
            if (result) {
                console.log("isExternalStorageRemovable returns: " + result);
            }
        },
        function (error) {
            console.log("isExternalStorageRemovable error: " + error);
        }
    );
} else {
    console.log("Plugin error: Env plugin not found (is it installed?)");
}

getDirectory

Parameters:

  • directory: (string) Special directory to look up (see "Directories" below).
  • successCallback: Callback that returns the string name of the specified directory on this device.
  • errorCallback: Callback that executes if an error occurs during the call.

Directories

Following are valid string values for the directory parameter above:

| String value | Android directory | |:-:|:-:| | "Alarms" | DIRECTORY_ALARMS | | "DCIM" | DIRECTORY_DCIM | | "Documents" | DIRECTORY_DOCUMENTS | | "Downloads" | DIRECTORY_DOWNLOADS | | "Movies" | DIRECTORY_MOVIES | | "Music" | DIRECTORY_MUSIC | | "Notifications" | DIRECTORY_NOTIFICATIONS | | "Pictures" | DIRECTORY_PICTURES | | "Podcasts" | DIRECTORY_PODCASTS | | "Ringtones" | DIRECTORY_RINGTONES |

Example

if (navigator.Env) {
    console.log("Env object in navigator");
    navigator.Env.getDirectory("Documents", 
        function (path) {
            if (path) {
                console.log("getDirectory(Documents) returns: " + path);
            }
        },
        function (error) {
            console.log("getDirectory error: " + error);
        }
    );
} else {
    console.log("Plugin error: Env plugin not found (is it installed?)");
}

getExternalStoragePublicDirectory

DEPRECATION WARNING This method has been deprecated on Android API 29 and later.

Parameters:

  • directory: (string) Directory to look up. This needs to be one of the strings returned by the getDirectory() call above.
  • successCallback: Callback that returns the full path string of the specified directory on this device.
  • errorCallback: Callback that executes if an error occurs during the call.

Example

if (navigator.Env) {
    console.log("Env object in navigator");
    // attempt to get Environment.DIRECTORY_DOWNLOADS
    navigator.Env.getDirectory("Downloads", 
        function (dirName) {
            if (dirName) {
                console.log("getDirectory(Downloads) returns: " + dirName);
                // success -- now try to get the full path for the shared Downloads directory
                navigator.Env.getExternalStoragePublicDirectory(dirName,
                    function(fullPath) {
                        console.log("getExternalStoragePublicDirectory(Downloads) returns: " + fullPath);
                    }, function (error) {
                        console.log("getExternalStoragePublicDirectory error: " + error);
                    }
                );
            }
        },
        function (error) {
            console.log("getDirectory error: " + error);
        }
    );
} else {
    console.log("Plugin error: Env plugin not found (is it installed?)");
}