【发布时间】:2017-04-16 14:10:47
【问题描述】:
我在我的data.txtfile www ionic 应用程序文件夹中放置了一个文件。我只想将此文件复制到另一个文件夹,更具体地说是在 data/data 文件夹中。在复制之前我写了一个代码来检查它是否存在?
function checkIfFileExists(path) {
alert("file path : " + path);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
fileSystem.root.getFile(path, { create: false }, fileExists, fileDoesNotExist);
}, getFSFail); //of requestFileSystem
}
function fileExists(fileEntry) {
alert("File " + fileEntry.fullPath + " exists!");
}
function fileDoesNotExist() {
alert("file does not exist");
}
function getFSFail(evt) {
console.log(evt.target.error.code);
}
checkIfFileExists(cordova.file.applicationDirectory + 'www/index.html');
此代码返回file does not exist 为什么??
这就是我无法复制我的数据库文件的原因。如果不是这样,任何人都可以帮助使用cordova 应用程序中的预填充数据库。
【问题讨论】: