Skip to content

Cordova shell give you an easy access to the device filesystem.

Notifications You must be signed in to change notification settings

fabsharp/cordova-shell

Repository files navigation

Cordova shell is a javascript wrapper around the Apache Cordova Plugin File to give you an easy access to the device filesystem.

For documentation see the definition file

shell.consoleLog(true);

shell.ls('cdvfile://localhost/persistent/');

shell.mkdir('cdvfile://localhost/persistent/data/');

shell.writeText('hello world', 'cdvfile://localhost/persistent/data/hello.txt');

shell.copy('cdvfile://localhost/persistent/data/hello.txt', cordova.file.dataDirectory);

shell.ls(cordova.file.dataDirectory);

shell.download('https://www.w3.org/TR/PNG/iso_8859-1.txt', 'cdvfile://localhost/persistent/data/iso.txt', progressCallback);

shell.readText('cdvfile://localhost/persistent/data/iso.txt')

shell.remove('cdvfile://localhost/persistent/data/iso.txt');

shell.remove('cdvfile://localhost/persistent/data/');

shell.fileTree('cdvfile://localhost/persistent/'); //return relative paths

shell.fileTree('cdvfile://localhost/persistent/', false); //return absolute paths

Install

cordova plugin add cordova-plugin-file
  • Download cordova-shell.js and copy it to your cordova www directory

  • reference the script in www/index.html

<script src="cordova-shell.js"></script>
<script>
    shell.ls('cdvfile://localhost/persistent');
</script>

Import module

npm install cordova-shell
import {shell} from 'cordova-shell';

shell.ls("cdvfile://localhost/persistent").then(entries => {
    console.log(entries);
});