android.database.sqlite.SQLiteException: no such column: location (code 1): , while compiling: UPDATE user SET email=?,location=?,mobile=? WHERE id=?
这是我用于更新信息的代码:
public void updateUserInfo(String mobile, String email, String location) {
SQLiteDatabase db = this.getWritableDatabase();
String[] tablei = new String[1];
tablei[0] = "1";
ContentValues values = new ContentValues();
values.put(KEY_MOBILE, mobile); // Mobile
values.put(KEY_EMAIL, email); // Email
values.put(KEY_LOCATION, location); // Location
// Inserting Row
//long id = db.update().insert(TABLE_USER, null, values);
long id = db.update(TABLE_USER, values, "id=?", tablei);
db.close(); // Closing database connection
Log.d(TAG, "Info of user updated in sqlite: " + id);
}
这是我的表,其中使用了所有列:
private static final String KEY_ID = "id";
private static final String KEY_LOCATION = "location";
.....
String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_USER + "("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_NAME + " TEXT,"
+ KEY_EMAIL + " TEXT UNIQUE," + KEY_APIKEY + " TEXT,"
+ KEY_MOBILE + " TEXT," + KEY_LOCATION + " TEXT,"
+ KEY_CREATED_AT + " TEXT" + ")";
提前感谢您的帮助!