Question

Im using the pattern presented here: http://www.youtube.com/watch?v=xHXn3Kg2IQE (although very slightly modified. The modification should not be terribly relevant for this question).

The situation is like this: The activity queries the ContentProvider for a resource. The ContentProvider could immidiately return the tuples currently in the local DB, initiate the REST method, and return the new data from the server to a ContentObserver.

But this feels a little strange to me, because then you have to handle the data in 2 places - Once for the local DB, and once for when the REST method completes. Ofcourse, you could create a method for handling it, which helps, but still? If i could manually trigger the ContentObserver, without actually changing the content, handling the data would only happen in one place - in the ContentObserver. Is this possible?

The activity would then query the ContentProvider, which would trigger the ContentObserver with the resources from the local database. The webservice would be queried and once the REST method completes the ContentObserver would be triggered again (As we now also have the data from the webservice in addition to the data already available in the local database).

If its possible, initiating the query to the ContentProvider would become a bit awkward, as the cursor returned from the ContentProvider would likely be empty/null, but isnt that acceptable if it allows me to handle everything in one place?

Was it helpful?

Solution

I'm not totally clear what you want, but here's a guess...

ContentResolver cr = getActivity().getContentResolver();

Uri uri = Uri for the content you are interested in 

cr.notifyChange(uri, null);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top