0
這是我第一次在android上干預sqlite。Sqlite更新記錄
隨後的教程,創造了SQliteHelper類,還有這個方法裏面:
// Updating single profile
public int updateProfile(Profile profile) {
// 1. get reference to writable DB
SQLiteDatabase db = this.getWritableDatabase();
// 2. create ContentValues to add key "column"/value
ContentValues values = new ContentValues();
values.put("cpf", profile.getCpf()); // get cpf
values.put("nome", profile.getNome()); // get nome
values.put("phone", profile.getPhone()); // get nome
// 3. updating row
int i = db.update(TABLE_PROFILES, //table
values, // column/value
KEY_ID+" = ?", // selections
new String[] { String.valueOf(profile.getId()) }); //selection args
// 4. close
db.close();
return i;
}
但是,我不知道如何使用它..
我知道,爲了得到個人資料我做了以下幾點:
MySQLiteHelper db = new MySQLiteHelper(view.getContext());
db.updateProfile(db.getProfile(0));
但是我怎麼實際更新它呢?
有道理,謝謝。 – Rosenberg