I am developing an android app, where I want to update a column in a row based on a where clause which comprises of two values. Below is what I have tried.
public void setlocationsetcolumn(double lats , double longs, String setvalue)
{
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Loc_set, setvalue);
db.update(TABLE_LATLONG, values, " WHERE "+Loc_lati +" = " + lats+" AND "+Loc_longi+" = "+longs, null);
}
I wan to update the Loc_set, based on the lats & longs values. but i am getting a force close. Am I doing something wrong here. Please help.Thanks!
below snippet will help you.
String[] args = new String[]{lats, longs};
db.update(TABLE_LATLONG, values, "Loc_lati=? AND Loc_longi=?", args);
Drop the WHERE
String . Try this :
db.update(TABLE_LATLONG, values, Loc_lati +" = " + lats+" AND "+Loc_longi+" = "+longs, null);
However, I Don't know what loc_lati and loc_longi are, hopefully columns in your db.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With