I ran into a problem with an Android application, where I needed to create multiple database tables. There’s a small catch to remember that may save you a headache – but it’s just a matter of coding the database access layer right.
Your database access layer may define SQL code for database tables like this:
The SQL is then executed so:
However, there’s a danger here. Android does not actually allow you to execute more than one SQL statement with a single execution. It is necessary to split up the table creation SQL into two separate statements, which are executed one by one:
The statements are then executed like this:
If you don’t do this, the second table will never get created, and no warning is issued about it.