David Given wrote:
> I want to initialise my database on app startup from a file containing 
> quite a lot of SQL.
> 
> I can't find any way of executing multiple statements at once. 
> SQLiteDatabase.execSQL() is restricted to running *one* statement at a 
> time. I know the SQLite library is capable of doing this; is there any 
> way of accessing this from Java?
> 
> (Right now I have a very simple parser that splits the input file up 
> into statements by looking for ; characters, but as I'm about to start 
> needing triggers that will fail.)

You could:

-- Package the database itself with your application, rather than
running SQL at startup

-- Split on newlines rather than semicolons

-- Package your SQL in some other structured form (e.g., JSON, XML) that
does not require manual parsing

You could try using System.exec() to run the sqlite3 command and run the
batch that way, but sqlite3 could get dumped in some future Android
release to save firmware space, so I would not rely upon it.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in Germany, 18-22 January 2010: http://bignerdranch.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to