我有一个Cordova移动应用程序,我正在实施导入功能。用户需要在clients.db
文件夹中放置文件Documents
,从应用程序启动导入功能,应用程序本身应将此文件从当前位置复制到内部数据库存储,准备好作为SQLite数据库打开
这是我的代码:
window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory + "/Documents/clients.db", function(fs) {
window.resolveLocalFileSystemURL("file://data/data/com.app.clients/databases/",function(directoryEntry) {
fs.copyTo(directoryEntry, "clients.db", function() {
//done
}, function(err) {
//here I get err = 1
});
}, function(){
//err
});
}, function(){
//err
});
文件clients.db
位于Documents
文件夹中,但是当我启动代码时,copyTo
函数无法返回err = 1,这意味着找不到文件。
调试时我注意到变量fs
已正确定价:
filesystem : FileSystem fullPath : "/Documents/clients.db" isDirectory : false isFile : true name : "clients.db" nativeURL : "file:///storage/emulated/0/Documents/clients.db"
__proto__ : Entry
directoryEntry
也是valorized correclty,它被识别为目录
答案 0 :(得分:1)
网址是否与文件夹路径匹配?看起来很奇怪。
答案 1 :(得分:0)
参考我的代码here。 from位置应该在1st resolveLocalFileSystemURL调用&到第二个位置。