我有一个使用名为 ANIMAL 的工作表运行的应用程序。在第一次创建这个表时,它只包含 _id 和 animal_name 列。
现在我正在尝试扩展它,包括一个 animal_biography 列,但是我遇到了一点困难。起初我以为我只是升级我的 CREATE_TABLE 语句以包含动物生物的一个例子:
private static final String DATABASE_CREATE =
"create table " + ANIMALS_TABLE +
" (_id integer primary key autoincrement, " +
"animal_name text not null, " +
"biography text not null);";
但是,查看 logcat 时,它告诉我列传记在尝试插入时不存在。
现在,我尝试使用onUpgrade()
并包含代码来升级数据库
db.execSQL("ALTER TABLE" + DATABASE_NAME);
db.execSQL(DATABASE_CREATE);
但这也不能解决问题。有没有人对如何解决这个问题有任何指示?