无法从 JavaScript 打开 sqlite 数据库
我正在尝试从 JS 端读取由 Android 活动或服务创建/更新的 sqlite 数据库。
但是当我调用 window.openDatabase() 方法时,LogCat 上会出现以下消息,并且 Query 返回“没有这样的表”错误。
物理 .db 文件在那里,似乎可以从 Java 代码中访问,但不能 从 JavaScript 代码访问。卸载或清除数据并重新安装应用程序对此没有帮助。
我不知道如何解决这个错误,请帮助&非常感谢任何建议。
phonegap sqlite 错误代码=14 I/Database(2138):sqlite 返回:错误代码 = 14,msg = 无法在第 27205 行打开文件
I'm trying to read sqlite database from the JS side which is created/updated by Android Activity or Service.
But when I call window.openDatabase() method the message below is appear on the LogCat, and Query returns 'no such table' error.
physical .db file is there and seems to accessible from within the Java code, but cannot
access from the JavaScript code. Uninstall or Clear data and reinstall the app did no help with this.
I have no clue to solve this error please help & any suggestions are very appreciated.
phonegap sqlite error code=14
I/Database(2138): sqlite returned: error code = 14, msg = cannot open file at line 27205
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试从 Javascript 代码访问 Activity 创建的数据库,以下线程可能会回答您的问题:
如何从 Android 应用程序中托管的 webView 调用 window.openDatabase?
If you are trying to access the database created by Activity from the Javascript code, the following thread might answer your question:
How do I call window.openDatabase from a webView hosted in an android application?
在这里,我假设您正在使用 Phonegap/Cordova android 应用程序。
我也遇到了同样的问题,但我发现这个问题的出现是因为Java和JS都在不同的2个地方创建数据库。所以要解决它,请使用这个 插件用于访问 android 在 Javascript 中创建的数据库。该插件从 Java 创建数据库的位置访问数据库。
Here I am assuming that you are working with Phonegap/Cordova android application .
I also faced the same problem , but I found that this problem is arising because Java and JS both are creating DB at different-2 places.So to solve it use this pluginto access DB created by android in Javascript . This plugin access DB from where Java creates it.