Thursday, November 18, 2010

Fetch data from html

    public void Fetch_Data(){
     line = "";
        try {
      // Perform action on click
      //Log.w("Fetchhhhhhhhhhhhh","You are going to fetch tip data");
      String tempStr = ""; 
      // Initiate the url connection
      URL url = new URL(The_URL);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      // Get the response
      BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
      while ( (tempStr= rd.readLine()) != null) {
       line = line + tempStr;
       }
      rd = null;
      conn.disconnect();
      }
     catch (Exception e) {
      Log.w("===========",e);

     }
    }

No comments:

Post a Comment