我有一个科尔多瓦移动应用程序,并且正在实施导入功能。用户有望置入文件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
是增值的correclty也是一样,它认为是一个目录
你的意思是file:///data/data/com.app.clients/databases/ ??为什么它看起来很奇怪? –
尝试使用任何cordova函数的根路径... – crak
一个是解析原点,另一个是解析目的地。难道我做错了什么? –