Detect if a table contains a column in Android/sqlite
Posted
by sandis
on Stack Overflow
See other posts from Stack Overflow
or by sandis
Published on 2010-04-20T13:20:15Z
Indexed on
2010/04/20
13:43 UTC
Read the original article
Hit count: 410
So I have an app on the market, and with an update I want to add some columns to the database. No problems so far. But I want to detect if the database in use is missing these columns, and add them if this is the case. I need this to be done dynamically and not just after the update to the new version, because the application is supposed to still be able to import older databases. Normally I would be able to use the PRAGMA query, but Im not sure how to do this with Android. I cant use execSQL since it is a query, and I cant figure out how to use PRAGMA with the query()-function.
Ofcourse I could just catch exceptions and then add the column, or always add the columns to each table before I start to work with it, but that is not a neat solution.
Cheers,
© Stack Overflow or respective owner