在发布这个问题之前,我已经阅读了以下帖子:
我尝试重新安装应用程序,但它抛出一个异常,指出列 uid_name 不存在!这里有什么错误?
我有一个数据库类,其中有以下功能:
private static final String KEY_ID = "og_nid";
private static final String KEY_TITLE = "og_title";
private static final String KEY_UID = "og_uid";
private static final String KEY_UID_NAME = "uid_name";
public void onCreate(SQLiteDatabase db) {
String CREATE_SURVEYS_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_SURVEYS + "("
+ KEY_ID + " INTEGER PRIMARY KEY, " + KEY_TITLE + " TEXT, "
+ KEY_UID + " TEXT, " + KEY_UID_NAME + "TEXT "+ ")";
db.execSQL(CREATE_SURVEYS_TABLE);
}
void addSurvey(Survey survey) {
SQLiteDatabase db = this.getWritableDatabase();
this.onCreate(db);
ContentValues values = new ContentValues();
values.put(KEY_ID, survey.get_id()); // Contact Name
values.put(KEY_TITLE, survey.get_title());
values.put(KEY_UID, survey.get_uid());
values.put(KEY_UID_NAME, survey.get_name());
// Contact Phone
// Inserting Row
db.insert(TABLE_SURVEYS, null, values);
db.close(); // Closing database connection
}