Can RESTful server response be read into a Cursor?

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Can RESTful server response be read into a Cursor?

Postby FredB » Thu Oct 29, 2009 7:14 pm

I would like to have the option of using an offline (SQLite) db or an online (mySQL) db.

I am tying to use the content providers, as android suggests. This works fine for the SQLite db. However, to do so for the server, I need an override method for the 'public Cursor query(uri....)' in 'ContentProvider'. I can get my data in xml form (through a RESTful http request), but I don't see any way (at least no way that doesn't feel like a ridiculous hack) to get from there to a Cursor.

Am I missing something w/ Content Providers? I keep reading that they can be "anything", but have yet to find any example that uses anything other than a local sqlite db. Is there any any elegant way to get from the RESTful request (or any other request for that matter) to an Android Cursor? If it means creating a temporary local sqlite db from my server response I guess I can live with that...

Regards,

Fred
Fred B
FredB
Freshman
Freshman
 
Posts: 4
Joined: Thu Oct 29, 2009 6:39 pm

Top

Postby padde » Thu Oct 29, 2009 7:47 pm

I think the direct way of creating a cursor on your RESTful requests is reeeealy hard.
My guess is you have to extend existing cursor class and possibly much more.

I would suggest you create a common sqlite db on the device and build a contentprovider
for it. Then you store your RESTful responses via contentprovider into the sqlite db.
From there its a piece of cake to get a cursor and so on.

At least this is one solution for the problem (at least if i got it right *g*) thats not a hack..
just a bit cumbersome.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

thanks

Postby FredB » Thu Oct 29, 2009 8:57 pm

Pedde,

Thanks for the response. I was kind of anticipating that I would need a local db. As you suggest, the effort to avoid having a local db is probably not worth it.

Regards,

Fred
Fred B
FredB
Freshman
Freshman
 
Posts: 4
Joined: Thu Oct 29, 2009 6:39 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 2 guests