从SQLite3数据库中提取“创建”字符串

时间:2010-08-25 18:37:50

标签: android sqlite oncreate

是否有一种简单的方法可以从Android中的每个表中获取CREATE字符串,而不是在onCreate覆盖中重新定义它们。我很生气,只为每张桌子解析整个事情,但我希望有一种我还没有找到的更简单的方法。

1 个答案:

答案 0 :(得分:2)

使用内置表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)

请参阅:SQLite3 FAQ #7