android - Pass id int into query -
i have query pass parameters groupid
, query not recognize number(group id)
.all values reaching query( debugged). query, can see if structure ok?
public cursor updategrupo(string nomegrupo,int idgroup){ sqlitedatabase db = this.getreadabledatabase(); //does not put id in "idgroup" cursor c = db.rawquery("update '"+tablegrupo+"' set '"+nomegrupo+"' = '"+nomegrupo+"' '"+idgrupo+"' = '"+idgroup+"'", new string[]{}); return c; }
- you should use
sqlitedatabase
writable modegetwritabledatabase()
. you should use below method updating data:
update(string table, contentvalues values, string whereclause, string[] whereargs)
try this:
public void updategrupo(string nomegrupo,int idgroup) { sqlitedatabase db = this.getwritabledatabase(); contentvalues values = new contentvalues(); values.put(nomegrupo, nomegrupo); db.update(tablegrupo, values, idgrupo + " = ? " , new string[]{string.valueof(idgroup)}); }
Comments
Post a Comment