getting exception in updating data base sqlite in android -


to update row in data base when press button

public void updatecontact(long id, string x, string y,string angle)         {         contentvalues editcon = new contentvalues();         editcon.put(key_x, x);         editcon.put(key_y, y);         editcon.put(key_angle, angle);          ourdatabase.update(database_table, editcon, key_rowid + id, null);          } 

and use entry.updatecontact(1, double.tostring(db1), double.tostring(db2), double.tostring(db3));

but exception: no such colum: _id1 (code1): , while compiling: update savedtable set position_y=?, position_x=?, position_angle=? where_id1

even though have database 1 row ( create entry in oncreate method of main activity)

key_rowid + id not work expect! key_rowid string containing _id , id variable contains 1 result in _id1.

you need this:

ourdatabase.update(database_table, editcon, key_rowid + "=" + id, null); 

or better:

ourdatabase.update(database_table, editcon, key_rowid + "=?", new string[]{string.valueof(id)}); 

edit:

// pseudocode cursor c = ourdatabase.query(database_table, null, null....); if (c != null) {     if (c.getcount() >= 1) {         // there entry - update     } else {          // no entry - create entry     } } else {     // error? definitively no entry create 1 } 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -