{"id":19481171,"url":"https://github.com/adapt-it/cordova-env","last_synced_at":"2025-04-25T15:31:44.216Z","repository":{"id":56823865,"uuid":"109420312","full_name":"adapt-it/cordova-env","owner":"adapt-it","description":"Cordova plugin for accessing the Android Environment object","archived":false,"fork":false,"pushed_at":"2021-01-20T15:19:01.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-20T01:31:07.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adapt-it.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-03T16:48:40.000Z","updated_at":"2021-01-20T15:19:04.000Z","dependencies_parsed_at":"2022-09-01T13:02:35.637Z","dependency_job_id":null,"html_url":"https://github.com/adapt-it/cordova-env","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adapt-it%2Fcordova-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adapt-it%2Fcordova-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adapt-it%2Fcordova-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adapt-it%2Fcordova-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adapt-it","download_url":"https://codeload.github.com/adapt-it/cordova-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250844349,"owners_count":21496556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T20:01:31.946Z","updated_at":"2025-04-25T15:31:43.831Z","avatar_url":"https://github.com/adapt-it.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!---\n    Licensed to the Apache Software Foundation (ASF) under one\n    or more contributor license agreements.  See the NOTICE file\n    distributed with this work for additional information\n    regarding copyright ownership.  The ASF licenses this file\n    to you under the Apache License, Version 2.0 (the\n    \"License\"); you may not use this file except in compliance\n    with the License.  You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing,\n    software distributed under the License is distributed on an\n    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n    KIND, either express or implied.  See the License for the\n    specific language governing permissions and limitations\n    under the License.\n--\u003e\n\n# cordova-plugin-env\n\n| Download Activity | Travis CI | Snyk |\n|:-:|:-:|:-:|\n| [![npm](https://img.shields.io/npm/dm/cordova-plugin-env.svg)](https://www.npmjs.com/package/cordova-plugin-env) | [![Build Status](https://travis-ci.org/adapt-it/cordova-env.svg?branch=master)](https://travis-ci.org/adapt-it/cordova-env) | [![Known Vulnerabilities](https://snyk.io/test/github/adapt-it/cordova-env/badge.svg)](https://snyk.io/test/github/adapt-it/cordova-env) |\n\nA small Cordova plugin that exposes Android's [Environment](https://developer.android.com/reference/android/os/Environment) object. \n\nThis plugin defines a global `Environment` object, which provides access to the common directories and helper methods available on Android's Environment object. The `Environment` object is available from the `navigator` object after the `deviceready` event fires.\n\n    document.addEventListener(\"deviceready\", onDeviceReady, false);\n    function onDeviceReady() {\n        console.log(navigator.Env);\n    }\n\n## Installation\n\nFrom the Command line:\n\n    cordova plugin add cordova-plugin-env\n\nConfig.xml for PhoneGap Build:\n\n    \u003cgap:plugin name=\"cordova-plugin-env\" source=\"npm\" /\u003e\n    \nThese commands will install the plugin from npm. You can find this plugin up on npm [here](https://www.npmjs.com/package/cordova-plugin-env), or by searching for `ecosystem:cordova` in the npm registry like [this](https://www.npmjs.com/search?q=ecosystem%3Acordova). \n\n\n## Supported Platform\n\n- Android\n\n# Env\n\nThe `Env` object provides a way to access the directories -- and some helper methods -- exposed by the Android [Environment](https://developer.android.com/reference/android/os/Environment) object.\n\n## Methods\n\nCurrently this plugin provides the following methods:\n\n- isExternalStorageEmulated\n- isExternalStorageRemovable\n- isExternalStorageManager\n- getExternalStorageState\n- getDirectory\n- getExternalStoragePublicDirectory (deprecated in Android API 29, but still available)\n\n### isExternalStorageEmulated\n\n**Parameters:** \n\n- **successCallback**: Callback that returns \"true\" if the external storage is emulated.\n- **errorCallback:** Callback that executes if an error occurs during the call.\n\n### Example\n\n    if (navigator.Env) {\n        console.log(\"Env object in navigator\");\n        navigator.Env.isExternalStorageEmulated(\n            function (result) {\n                if (result) {\n                    console.log(\"isExternalStorageEmulated returns: \" + result);\n                }\n            },\n            function (error) {\n                console.log(\"isExternalStorageEmulated error: \" + error);\n            }\n        );\n    } else {\n        console.log(\"Plugin error: Env plugin not found (is it installed?)\");\n    }\n\n### isExternalStorageRemovable\n\n**Parameters:** \n\n- **successCallback**: Callback that returns \"true\" if the external storage is removable.\n- **errorCallback:** Callback that executes if an error occurs during the call.\n\n### Example\n\n    if (navigator.Env) {\n        console.log(\"Env object in navigator\");\n        navigator.Env.isExternalStorageRemovable(\n            function (result) {\n                if (result) {\n                    console.log(\"isExternalStorageRemovable returns: \" + result);\n                }\n            },\n            function (error) {\n                console.log(\"isExternalStorageRemovable error: \" + error);\n            }\n        );\n    } else {\n        console.log(\"Plugin error: Env plugin not found (is it installed?)\");\n    }\n\n### isExternalStorageManager\n\n**Parameters:** \n\n- **successCallback**: Callback that returns \"true\" if the app has [All Files Access](https://developer.android.com/reference/android/provider/Settings?hl=en#ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION).\n- **errorCallback:** Callback that executes if an error occurs during the call.\n\n### Example\n\n    if (navigator.Env) {\n        console.log(\"Env object in navigator\");\n        navigator.Env.isExternalStorageManager(\n            function (result) {\n                if (result) {\n                    console.log(\"isExternalStorageManager returns: \" + result);\n                }\n            },\n            function (error) {\n                console.log(\"isExternalStorageRemovable error: \" + error);\n            }\n        );\n    } else {\n        console.log(\"Plugin error: Env plugin not found (is it installed?)\");\n    }\n\n### getExternalStorageState\n\n**Parameters:** \n\n- **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.\n- **errorCallback:** Callback that executes if an error occurs during the call.\n\n### Example\n\n    if (navigator.Env) {\n        console.log(\"Env object in navigator\");\n        navigator.Env.getExternalStorageState(\n            function (state) {\n                if (state) {\n                    console.log(\"External storage state: \" + state);\n                }\n            },\n            function (error) {\n                console.log(\"getExternalStorageState error: \" + error);\n            }\n        );\n    } else {\n        console.log(\"Plugin error: Env plugin not found (is it installed?)\");\n    }\n\n### getDirectory\n\n**Parameters:** \n\n- **directory**: (string) Special directory to look up (see \"Directories\" below).\n- **successCallback**: Callback that returns the string name of the specified directory on this device.\n- **errorCallback:** Callback that executes if an error occurs during the call.\n\n### Directories\n\nFollowing are valid string values for the **directory** parameter above:\n\n| String value | Android directory | \n|:-:|:-:|\n| \"Alarms\" | DIRECTORY_ALARMS |\n| \"DCIM\" | DIRECTORY_DCIM |\n| \"Documents\" | DIRECTORY_DOCUMENTS |\n| \"Downloads\" | DIRECTORY_DOWNLOADS |\n| \"Movies\" | DIRECTORY_MOVIES |\n| \"Music\" | DIRECTORY_MUSIC |\n| \"Notifications\" | DIRECTORY_NOTIFICATIONS |\n| \"Pictures\" | DIRECTORY_PICTURES |\n| \"Podcasts\" | DIRECTORY_PODCASTS |\n| \"Ringtones\" | DIRECTORY_RINGTONES |\n\n### Example\n\n    if (navigator.Env) {\n        console.log(\"Env object in navigator\");\n        navigator.Env.getDirectory(\"Documents\", \n            function (path) {\n                if (path) {\n                    console.log(\"getDirectory(Documents) returns: \" + path);\n                }\n            },\n            function (error) {\n                console.log(\"getDirectory error: \" + error);\n            }\n        );\n    } else {\n        console.log(\"Plugin error: Env plugin not found (is it installed?)\");\n    }\n\n### getExternalStoragePublicDirectory\n\n**DEPRECATION WARNING**\nThis method has been deprecated on Android API 29 and later. \n\n**Parameters:** \n\n- **directory**: (string) Directory to look up. This needs to be one of the strings returned by the getDirectory() call above.\n- **successCallback**: Callback that returns the full path string of the specified directory on this device.\n- **errorCallback:** Callback that executes if an error occurs during the call.\n\n\n### Example\n\n    if (navigator.Env) {\n        console.log(\"Env object in navigator\");\n        // attempt to get Environment.DIRECTORY_DOWNLOADS\n        navigator.Env.getDirectory(\"Downloads\", \n            function (dirName) {\n                if (dirName) {\n                    console.log(\"getDirectory(Downloads) returns: \" + dirName);\n                    // success -- now try to get the full path for the shared Downloads directory\n                    navigator.Env.getExternalStoragePublicDirectory(dirName,\n                        function(fullPath) {\n                            console.log(\"getExternalStoragePublicDirectory(Downloads) returns: \" + fullPath);\n                        }, function (error) {\n                            console.log(\"getExternalStoragePublicDirectory error: \" + error);\n                        }\n                    );\n                }\n            },\n            function (error) {\n                console.log(\"getDirectory error: \" + error);\n            }\n        );\n    } else {\n        console.log(\"Plugin error: Env plugin not found (is it installed?)\");\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadapt-it%2Fcordova-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadapt-it%2Fcordova-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadapt-it%2Fcordova-env/lists"}