I\'ve followed a standard tutorial for building a database with Android. I\'ve created a class called DbHelper which extends SQLiteOpenHelper. I\'ve Overridden the create
Well, in my case, I am excuting queries from a file which I saved as an asset This is the solution I used+-
String script = readAsset(CREATE_SCRIPT);//readAsset is a method i use to get the file contents
try {
String[] queries = script.split(";");
for(String query : queries){
db.execSQL(query);
}
} catch (Exception e) {
.....
EDIT
In my case, the Queries were simple insert queries which I had full control over. However, the issue has been raised concerning queries with ";" inside them.
@TWiStErRob suggests using
script.split(";$");// $ meaning end of line. You will need to use RegexOption.MULTILINE for this to work
or
script.split(";\n");// but you will need to ensure that each query is on a different line