I want to render data from android cache memory JS file stored in my cordova project so I wrote html code as below
<script src="file:///data/data/com.stifirestop.systems2/files/system_menu_data.js"></script>
JS file code for download
var fileTransfer = new FileTransfer();
var url = "https://systems.stifirestop.com/api/data/system_menu_data.js";
var targetPath = cordova.file.dataDirectory + "system_menu_data.js";
console.log("targetPath menu", targetPath);
fileTransfer.download(
url,
targetPath,
function (entry) {
console.log("Download complete: menu " + entry.toURL());
},
function (error) {
console.error("Download error:menu " + error.source + ", " + error.target + ", " + error.code);
},
true, // Optional, set to true if you want to overwrite existing files
);
// Second JS file
var url2 = "https://files.stifirestop.com/automate/systems_mongo_dump/mongo_dump.js";
var targetPath2 = cordova.file.dataDirectory + "mongo_dump.js";
console.log("targetPath2 mongo", targetPath2);
fileTransfer.download(
url2,
targetPath2,
function (entry) {
console.log("Download complete: mongo " + entry.toURL());
},
function (error) {
console.error("Download error:menu " + error.source + ", " + error.target + ", " + error.code);
},
true, // Optional, set to true if you want to overwrite existing files
);
File is successfully stored in my android files folder as below
When I run project in android device it give me error like
“Not allowed to load local resource: file:///data/data/com.stifirestop.systems2/files/system_menu_data.js”, source: https://localhost/index.html (0)
“Not allowed to load local resource: file:///data/data/com.stifirestop.systems2/files/mongo_dump.js”, source: https://localhost/index.html (0)
Any idea how I can solve this ?