cordova-plugin-shell-exec
cordova-plugin-shell-exec copied to clipboard
Read de external Storage sdcard
Hi
I'm tring to read (and then write) the sdcard using:
<script>
function lsfuncion() {
window.ShellExec.exec('ls /sdcard/', function(res){
console.log('exit status: ' + res.exitStatus)
console.log('cmd output: ' + res.output)
// alert(res.output)
var div = document.getElementById("COMMAND");
div.textContent = res.output;
var text = div.textContent;
})
}
</script>
<div id="wrapper">
<p><a href="#" class="btn" onclick="lsfuncion();">$ ls /sdcard</a></p>
</div>
<div id="COMMAND"></div>
but the result is: "Process has not yet termintated: 3577" ...that sound like the plugin can not read an external device mounted in the filesystem.
no problem if we try to read de root /
Can have a look for it, please?
honestly I have no idea how access rights are set on android on the /sdcard
dir.
However from apk itself you definitely can read and write sdcard, at least I have experience doing it via cordova file plugin.
From this table it seems that <sdcard>/
dir is both r/w, but maybe <sdcard>/
dir is actually some subdir of your /sdcard/
.
You'd want to add the Android permission for storage and files: WRITE_EXTERNAL_STORAGE