Retrieve data from website in android app-ThrowExceptions

Exception or error:

How can we retrieve data from a website and parse it into a readable format in the Android application? This means I want to extract data from website and use it in my android application, formatted in my way. It could be any website.

How to solve:

You can use jsoup to parse any kind of web page. Here you can find the jsoup library and full source code.

Here is an example:

To install in Eclipse:

  1. Right Click on project
  2. BuildPath
  3. Add External Archives
  4. select the .jar file

You can parse according to tag/parent/child very comfortably


Use this

DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("");
ResponseHandler<String> resHandler = new BasicResponseHandler();
String page = httpClient.execute(httpGet, resHandler);

This can be used to grab the whole webpage as a string of html, i.e., “<html>...</html>"

You need to declare the following ‘uses-permission’ in the android manifest xml file… answer by @Squonk here

And also check this answer


You can do the HTML parsing but it is not at all recommended instead ask the website owners to provide web services then you can parse that information.


Use the WebView. Simple!!

Leave a Reply

Your email address will not be published. Required fields are marked *