If it is just to run that command you could do something similar to what is in the Insert:
public int update(Uri uri, ContentValues contentValues, String selection,
String[] selectionArgs) {
int uriType = sURIMatcher.match(uri);
SQLiteDatabase sqlDB = database.getWritableDatabase();
int rowsUpdated = 0;
rowsUpdated = sqlDB.update(DATABASE_TABLE,
contentValues, selection, selectionArgs);
getContext().getContentResolver().notifyChange(uri,null);
return rowsUpdated;
}
The method call should already come with the pointer positioned in the record you want to update. This is done by selecting the URI with a contentResolver ().
My role is a saveState, I'll post it, maybe it helps, but I recommend you better understand how ContentProvider works, as this update you've always proposed will update all the records in your table. Is this the expected behavior?
private void saveState() {
String categoria = (String)mCategoria.getSelectedItem();
String descricao = (String)mDescricaoText.getText().toString();
String valor = mValorText.getText().toString();
String parcelas = mParcelasText.getText().toString();
String dataInclusao = mDataInclusao.getText().toString();
String dataVencimento = mDataVencimento.getText().toString();
if(descricao.length() == 0 && valor.length() == 0){
return;
}
ContentValues values = new ContentValues();
values.put(LancamentoTable.COLUMN_DESCRICAO, descricao);
values.put(LancamentoTable.COLUMN_VALOR, valor);
values.put(LancamentoTable.COLUMN_PARCELAS, parcelas);
values.put(LancamentoTable.COLUMN_ID_CATEGORIA, categoria);
values.put(LancamentoTable.COLUMN_DATA_INCLUSAO, dataInclusao);
values.put(LancamentoTable.COLUMN_DATA_VENCIMENTO, dataVencimento);
values.put(LancamentoTable.COLUMN_SINAL, (categoria.toString().equals("DEBITO") ? "-1" : "1"));
if(todoUri==null){
todoUri = getContentResolver().insert(SmartBillContentProvider.CONTENT_URI, values);
} else {
getContentResolver().update(todoUri, values, null, null);
}
}
My code is a beginner, I do not have much experience with Android, so I recommend the link below as a good base for working with SQLite on Android:
link