The scenario is the following:
The question,
Thanks!
I was looking for the same thing as you were and i got across DataDroid http://www.datadroidlib.com/. I think it's easier to use and it's a straightforward way to handle REST if your webservice is REST oriented.
Edit:
DataDroid is now marked as deprecated. They move to Robospice see https://github.com/stephanenicolas/robospice
Does anybody know how to build a Content Provider where the data source is a web service (like the ones mentioned above) and not a db?
Take into account the following answer may be considered a rather old-fashioned 'manual' method.
You could build a content provider that queries the web service, and converts the obtained result into a cursor.
To query the web service you could use HttpClient and HttpGet request. You can find a tutorial on MyKong on how to do this. There are also some newer alternatives to do this.
While parsing the search result you get from the web service, you can build your own cursor with the MatrixCursor class by adding rows with addRow() for every individual result.
If you were to do this, make sure you always call your Content Provider through a background thread (i.e. using CursorLoader, AsyncTask, or another form of threading), otherwise your network operation would end up on the main UI thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With