我不明白为什么我的笔记应用程序不断崩溃。我单击一个按钮插入一个注释,该注释显示在列表视图中,使用SQLite数据库。
给出的错误是:
(1) no such column: TITLE
FATAL EXCEPTION: main
Unable to resume activity: android.database.sqlite.SQLiteException: no such column: TITLE (code 1 SQLITE_ERROR): , while compiling: SELECT ID, TITLE FROM note_table
位于 :mainactivity.java
cursor = database.query(table_name, columns, where, where_args, group_by, having, order_by);
数据库:
public class DBOpenHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "notes.db";
public static final String TABLE_NAME = "note_table";
public static final String ID_COLUMN = "ID";
public static final String TITLE_COLUMN = "TITLE";
public static final String TEXT_COLUMN = "ITEM2";
public static final String DATE_COLUMN = "DATE";
SQLiteDatabase db = this.getWritableDatabase();
public DBOpenHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
String createTable = "CREATE TABLE " + TABLE_NAME + " (ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
" TITLE TEXT)";
db.execSQL(createTable);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("drop table notes_table");
onCreate(db);
}
我不明白为什么我会收到此错误消息,因为我的列名称是正确的。我尝试删除并重新编译我的应用程序,但没有成功。
慕桂英4014372
相关分类