What are the best ways to connect site and show it's data on an android application ? Also does I have to create anything on server where the site is for using JSON ? I am new to programming web android application's, though I searched a lot I didn't find anything which would explain me straight to the point.
-
You can request data from a site using basically any method you wish, be it POST, GET, JSON, etc. – Blender Dec 02 '11 at 18:03
-
@Blender - JSON is not a valid HTTP verb. – James Black Dec 02 '11 at 18:07
-
1@JamesBlack: I never mentioned HTTP. I just used JSON as a method of obtaining data. – Blender Dec 02 '11 at 18:08
-
@Blender James just means that there is no HTTP method called JSON - the way you listed them made it appear as though this was a request type, even though that's probably not what you intended. – DeaconDesperado Dec 02 '11 at 18:11
-
@DeaconDesperado: Pardon me for my ambiguity. – Blender Dec 02 '11 at 18:12
2 Answers
You're on the solid ground starting out using JSON as the interchange between the two.
Alot of popular mobile apps like Twitter and Foursquare have restful APIs set up to interact with their mobile clients by exchanging HTTP requests that contain data formatted as JSON. Most of the communication between the two can be accomplished with HTTP requests using the standard GET and POST methods.
A good place to start would be setting up some server endpoints that output this data and then setting up your android app to request and parse this data just like a browser would. You just need to set the appropriate mimetypes on your server end (application/json
).
Most modern server-side languages have implemented modules/functions that can take their native data structures and approximate them in serialized JSON (PHP's json_encode()
, python's json.dumps()
etc) These can be used to output data from within the app or database to your mobile client where it can be interpreted and used in the Java environment there.

- 9,977
- 9
- 47
- 77
To pass back JSON you need to set the mime type (http://stackoverflow.com/questions/477816/the-right-json-content-type), which is application/json
.
If you are passing back JSON or XML then the client just needs to make the appropriate http call, most likely GET, perhaps POST, to actually retrieve the information.
You can use something like this as a starting point:
http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/

- 41,583
- 10
- 86
- 166