问题
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