Android : Update singel cell of a row in an SQLite database on Android

on Sunday, September 28, 2014


I wont to update a single cell of a row in the database. However the row contains of 5 columns so and i would like to not passing all the other values as well as they should remain the same.


I have this code snippet:



Cursor cursor = db.query(STATION_TABLE, null, null, null, null, null, null);

//If the database already include some stations.
if(cursor.moveToFirst())
{
ContentValues stationValues = new ContentValues();

for(StopLocation station: stations)
{
stationValues.clear();

//The database already includes the station
if(cursor.getString(POS_STA_ID).equals(station.getId()))
{
values.put(KEY_STA_DISTANCE, "null");

db.update(STATION_TABLE, stationValues, KEY_STA_ID + "=?", new String[]{station.getId()});
}


The db.update method throws this exception:



java.lang.IllegalArgumentException: Empty values



Any ideas on how to solve this?


0 comments:

Post a Comment