I’ve worked with the sql lite database from Android before, but I always executed queries one by one. Now I need to execute a lot of queries to initialize a database of cities.
So I used to do
sql = "THE QUERY";
myDatabase.execSql(sql);
Now I want to execute a file like the following: http://joeylemmens.be/downloads/postcodes_en_gemeenten.sql
What’s the best way to do this?
I could store the whole file in a string and then do the above again, but there must be something better.
If your aim is to initialize the SQLite database with some default values then you should have version of the database having these default values, you can provide your application along with that default database version.
The other approach to read from a file & execute the sqls is also fine & i can not think of a better solution.
EDIT:
How to use already created database? see this.