I have a web app using filesaver.js to create some files that will be downloaded later to a user's computer. I transfered the same scripts files I am using for this web app in my cordova application. Everything is working perfect except the download button I have in my app. It won't fire anything. Is there any cordova plugin to use to get access to the file system of the device or something else I can do?
Here is some markup: html
<link rel="stylesheet" type="text/css" href="css/sliders.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/transformations.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"/></script>
<script type="text/javascript" src="js/save.js"></script>
<script src="js/bootbox.js" type="text/javascript"></script>
<script type="text/javascript" src="js/transformations.js"></script>
<div class="btn btn-block btn-success" onclick="savefile('hello.txt','maamaamamamam\nu')">Download code</div>
Js
$(document).ready(function(){
//some functions
});
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(cordova.file);
}
var myFileUrl = "kk";
function saveFile (fileName, fileData) {
// Get access to the file system
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
// Create the file.
fileSystem.root.getFile(fileName, { create: true, exclusive: false }, function (entry) {
// After you save the file, you can access it with this URL
myFileUrl = entry.toURL();
entry.createWriter(function (writer) {
writer.onwriteend = function (evt) {
alert("Successfully saved file to " + myFileUrl);
};
// Write to the file
writer.write(fileData);
}, function (error) {
alert("Error: Could not create file writer, " + error.code);
});
}, function (error) {
alert("Error: Could not create file, " + error.code);
});
}, function (evt) {
alert("Error: Could not access file system, " + evt.target.error.code);
});
}
The problem is that by using this code i get no errors but also nothing happens.Any help would be appreciated