在android中添加新列到现有数据库

时间:2014-07-04 11:40:26

标签: android

当我尝试将新列添加到我的应用程序前关闭

时,我有一个数据库

07-04 17:06:48.783:E / AndroidRuntime(17193):引起:android.database.sqlite.SQLiteException:没有这样的列:vpath :,编译时:SELECT _id,title,body,reminder_date_time,vpath来自提醒  这个错误请帮助我。

2 个答案:

答案 0 :(得分:1)

添加专栏:

db.execSQL("ALTER TABLE reminders ADD vpath text");

答案 1 :(得分:1)

 private static final String DATABASE_CREATE =
            "create table " + DATABASE_TABLE + " ("
                    + KEY_ROWID + " integer primary key autoincrement, "
                    + KEY_TITLE + " text not null, " 
                    + KEY_BODY + " text not null, " 
                    + KEY_DATE_TIME + " text not null, "+ KEY_VOICE + " text not null,);"; 

我已删除","在查询结束时,我的问题就解决了。

 private static final String DATABASE_CREATE =
            "create table " + DATABASE_TABLE + " ("
                    + KEY_ROWID + " integer primary key autoincrement, "
                    + KEY_TITLE + " text not null, " 
                    + KEY_BODY + " text not null, " 
                    + KEY_DATE_TIME + " text not null, "+ KEY_VOICE + " text not null);";