I am trying to update a specific row that uses auto_increment as a primary key. Basically, I initialize the table in one activity and I want to complete the table on another. So, I use the update feature to do it. However, when I log to see how many rows where affected I get 0 back.
Here is my code:
public void updateValue(String updatedValue){
String strFilter = " (" + primaryKey + "== "+ "(SELECT last_insert_rowid())" + ")";
ContentValues values = new ContentValues();
values.put(val, updatedValue);
db = this.getWritableDatabase();
int rows= db.update(myTable, values, strFilter, null);
Log.d(LOG_TAG, "The change has affected " + rows
+ " rows.");
db.close();
}
I think that the problem in the following line:
It should be written, I guess, in the following way:
But you should control the return of this part
(SELECT last_insert_rowid())if it returns last inserted row or not.