views:

21

answers:

1

Is there a simple way to get the CREATE string from each of your tables in Android instead of redefining them in onCreate override. I am annoyed enough to just parse the whole thing for each table, but I am hoping there is an easier way I have not found yet.

+1  A: 

Use built-in table sqlite_master

sqlite-3.7.2 e$ sqlite3
SQLite version 3.7.2
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table t1 (a, b, c integer);
sqlite> create table t2 (d, e, f text);
sqlite> select * from sqlite_master;
table|t1|t1|2|CREATE TABLE t1 (a, b, c integer)
table|t2|t2|3|CREATE TABLE t2 (d, e, f text)
sqlite> select sql from sqlite_master;
CREATE TABLE t1 (a, b, c integer)
CREATE TABLE t2 (d, e, f text)

See: SQLite3 FAQ #7

Doug Currie