its my first question here on this site.
well i have a problem regarding update query.
ContentValues args = new ContentValues();
args.put("j_id", str);
db.update(TABLE_NAME2, args, null, null);
i just want to add “where” clause into it.
like
UPDATE TABLE_NAME2
SET j_id=str
WHERE j_id = '-1'
So what should i do?
Instead of passing
nullas the third argument, you can pass theWHERE-clause. See the docs.In your case, this would look like this:
You should always use the prepared-statement syntax. Thus, you don’t actually add the value for the
WHERE-clause in the String but use the fourth argument which takes a String-array to replace the?in theWHERE-query-string.The first element of the String-array is replaced with the first
?in the query-string and so on. So in the end, this creates a WHERE-clause like this: