How to get JSON content from a RESTful server to a Android client?
I've built a REST server that aut开发者_运维百科omatically retrieves data from my database and returns it as JSON. I want to know, how I can get this JSON content to my mobile and turn it into a string so that I can store this in the mobile's database.
First you need to be able to parse your JSON string. For a simple parser I gave an answer earlier here: getting Json result in Android Just parse through the list and add them to the database. There are different database tutorials out there.
Database tutorial: http://www.vogella.de/articles/AndroidSQLite/article.html
To make it as easy as possible try to find out small tutorials for different sub tasks like REST to JSON and database handler.
Here is a tutorial for JSON parsing from a REST webservice:
http://www.josecgomez.com/2010/04/30/android-accessing-restfull-web-services-using-json/
Here is another more simple JSON example:
http://inchoo.net/mobile-development/android-development/simple-android-json-parsing-example-with-output-into-listactivity/
精彩评论