Dies ist mein erstes Mal Einmischung mit SQLite auf Android.Sqlite Aktualisieren eines Datensatzes
Gefolgt ein Tutorial und erstellt eine SQliteHelper Klasse, diese Methode dort Innere ist:
// 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;
}
Aber ich habe keine Ahnung, wie es zu benutzen ..
Ich weiß, dass, um das zu bekommen Profil Ich mache folgendes:
MySQLiteHelper db = new MySQLiteHelper(view.getContext());
db.updateProfile(db.getProfile(0));
Aber wie aktualisiere ich es eigentlich?
Sinn macht, danke. – Rosenberg