You can also use the update() , insert() , query() , delete() methods that Android gives you
The advantage is that you get the correct SQL syntax for free. It also eludes your variables that prevent bad things from "hax ' DROP TABLE '" when you use "hax ' DROP TABLE '" as an argument to ? .
The only thing that is not safe yet is to use column LIKE ? with arguments like "hello%world_" because % (matches any of several characters) and _ (matches any 1 char) is not escaped. You will need to avoid them manually (e.g. put a ! front of each _ or % ) and use
String whereClause = "LIKE ? ESCAPE '!'" String[] whereArgs = new String[] { likeEscape("bar")
Btw: your only line of code should work if you use
db.execSQL( "UPDATE " + Table_name + " SET " + availability + "=0 WHERE " + product_name + " like 'bar'");
source share