Blackberry - Attach pre-populated sqlite database

北慕城南 提交于 2019-12-25 08:25:11

问题


I have a pre-populated sqlite database and I need to attach this within my Blackberry app. I am using phonegap and therefore using the following javascript code to open my database and then run a select statement:

db = window.openDatabase("TaxCalculatorDB","1.0","Tax Calculator DB",1000000);
db.transaction(Manufacturer, errorCB, successCB);

However, when trying to run my select statement I get an error (ERROR: 1 no such table:user).

I have added my database files (which I have succesfully used in a iOS build) directly into the assets folder, exactly the same way I had done before. Do i need to move this database folder elsewhere?

Please advice, Thanks.


回答1:


You have to have Javascript create the database when using webworks. There is currently no way to import an existing sqlite db into a webworks app. (You tagged this as phonegap, but I think phonegap uses webworks to create the app)

The common workaround to this is to include a JSON or XML file with all the data to be loaded. When you create the database, read the included file and add that data to it.



来源:https://stackoverflow.com/questions/9738163/blackberry-attach-pre-populated-sqlite-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!