Help on updating values using contentresolver

3 views
Skip to first unread message

Achint

unread,
Apr 20, 2011, 5:16:46 AM4/20/11
to bpgc-android-community
So I want to overwrite the values stored in one of the rows of my
table and I'm executing the following statements :

ContentValues c = new ContentValues();
c.put(GeoPoints.ROUTE, defaultRouteName);
c.put(GeoPoints.GEOPOINTS_LAT, defaultLat);
c.put(GeoPoints.GEOPOINTS_LONG, defaultLon);
try{
referenceUri = getContentResolver().insert(GeoPoints.CONTENT_URI,
c);
Toast.makeText(this, "Record resources allocated",
Toast.LENGTH_LONG).show();

}catch(SQLiteException e){

Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG);
}


And later on I'm doing this to update the same record

stringRouteName = routeName.toString();
updateData.put(GeoPoints.ROUTE, stringRouteName);
updateData.put(GeoPoints.GEOPOINTS_LAT, latString);
updateData.put(GeoPoints.GEOPOINTS_LONG, longString);

debugUri = getContentResolver().insert(referenceUri, updateData);


It gives me an unknown Uri exception. Why? I thought the specific
record uri is returned?

Praveen

unread,
Apr 23, 2011, 3:13:24 PM4/23/11
to bpgc-android-community
try update(...) method instead of insert(...) to update... reference
API for more info...

Achintya Prakash

unread,
Apr 23, 2011, 4:22:26 PM4/23/11
to bpgc-androi...@googlegroups.com
Yeah, I got it.
Reply all
Reply to author
Forward
0 new messages