• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Json Help

I need to access some JSON info from an online repository. So far I've got an app that so far creates the URL currently as string.

When I try to -
searchURL = "localhost.com";
URL temp = new URL(searchURL);
- I get a malformedURLException.

Regardless of that, what do I need to know about setting up JSON? Are they any good tutorials or libraries that help me?
 
Firstly, you need to add "http://" To make the URL a valid URL.
When you say access, do you simply mean get the JSON file? If so, just make a GET request to the URL.
Example -
HttpURLConnection con = (HttpURLConnection) temp.openConnection();
con.setRequestMethod("GET");
Then just use inputstream and buffered reader to read the response and store it into a json file.
This could be JSON file = new JSON(responsebuilder.toString);
So just look up Buffered reader and Stringbuffer.
 
Back
Top Bottom