ListView Not Updating After Web Service Sync
I have impelmented SyncAdapter that calls webservice and insert/update database. I would like to show some of this data in ListView so i implemented ListFragment in witch the data
Solution 1:
I finally got this to work. So for anybody trying to do similar thing, you must include cursor.setNotificationUri(getContext().getContentResolver(), uri);
after your .query
in the ContentProvider
. And that is it...
But if you are like me and are receiving data from a web service, remember NOT to put .notifyDataSetChanged()
on ContentProvider .update/.insert/.delete
but on a adapter that is calling this methods in SyncAdapter
. In my example
mContentResolver.applyBatch(ScheduleContract.CONTENT_AUTHORITY, batch);
mContentResolver.notifyChange(DataContract.Obavijesti.CONTENT_URI, null);
I hope, for somebody, this will be helpful
Solution 2:
Try invalidating the view you're using after updating the information.
listview.invalidate();
Post a Comment for "ListView Not Updating After Web Service Sync"