Thursday, 15 April 2010

android - SQLiteDatabase updates only when the application is reopened -



android - SQLiteDatabase updates only when the application is reopened -

i have android app inserts info in database when click marker in map.

i have activity updates info(column) in database. doesn't update on first effort when close, exit app, run 1 time again , update info again, updates believe code right. problem?

process:

1st open

place marker

oninfowindowclick starts new activityforresult

fill fields

save (button)

return values update row

doesn't update

re-open

when existing marker clicked, fill fields, updates when saved when new marker placed, fill fields, doesn't update (means need reopen again)

call update:

contentvalues cv = new contentvalues(); cv.put(locationsdb.field_title, newreminder); cv.put(locationsdb.field_month, mm_final); cv.put(locationsdb.field_day, dd_final); cv.put(locationsdb.field_year, yy_final); getcontentresolver().update(locationscontentprovider.content_uri, cv, "lat=? , lng=?", new string[] {location_lat, location_lng});

locationcontentprovider.java:

public int update(uri uri, contentvalues values, string selection, string[] selectionargs){ int count; count = mlocationsdb.update(values, selection, selectionargs); homecoming count; }

locationsdb.java:

public int update(contentvalues contentvalues, string where, string[] whereargs){ int cnt = mdb.update(database_table, contentvalues, where, whereargs); homecoming cnt; }

most likely, sqlite database has changed, contentresolver not know it. in update() method of contentprovider, add together line of code:

this.getcontext().getcontentresolver().notifychange(uri, null);

this notifies contentresolver alter has occurred. resolver update ui components depend on data.

android sqlite

No comments:

Post a Comment