如何在phonegap中使用copyto api
我想将 sqlite db 复制到数据库文件夹,但不知道如何使用 copyto api:
function win(entry) {
console.log("New Path: " + entry.fullPath);
}
function fail(error) {
alert(error.code);
}
function copyFile(entry) {
var parent = document.getElementById('parent').value,
parentEntry = new DirectoryEntry({fullPath: parent});
// copy the file to a new directory and rename it
entry.copyTo(parentEntry, "file.copy", success, fail);
}
entry 是什么?我必须在哪里编写资产文件夹中的数据库路径?是否错误地在最后一行中表示成功但没有定义它?我必须写 win 吗?
i want to copy a sqlite db to the database folder but dont know how to use copyto api:
function win(entry) {
console.log("New Path: " + entry.fullPath);
}
function fail(error) {
alert(error.code);
}
function copyFile(entry) {
var parent = document.getElementById('parent').value,
parentEntry = new DirectoryEntry({fullPath: parent});
// copy the file to a new directory and rename it
entry.copyTo(parentEntry, "file.copy", success, fail);
}
what is entry? where to i have to write my db path form assets folder? is it mistyping that in the last line it said success but didn't define it? do i have to write win instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文件 API 无法访问资产目录内的文件。您需要编写一个插件。
The File API can't access files inside the asset directory. You'll need to write a plugin.
我通过向我的主要活动(java 代码)添加一些代码来做到这一点:
来源:
http://gauravstomar.blogspot.com/2011/08/prepopulate -sqlite-in-phonegap.html
I did it by adding some code to my main activity(java code):
source:
http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html