title: I fail to retrieve data from mysql in my android application
body: <p>I am new to android application development. I am developing an application that will retrieve news from mysql database. I first wrote PHP script that extract news title and content from database and ouputs the JSON encoded data successfully, then in my application i wrote the following codes that will take JSON encoded data and display it to my application. I tried to catch some errors as well and i realized that i get the error while taking the data and try to display them. please have look on my codes and try to help me debugging it as i don't get where exactly am i doing mistake.</p>
  
  <pre><code>package com.jetas.vpl;
  
  import java.io.BufferedReader;
  
  import java.io.InputStream;
  
  import java.io.InputStreamReader;
  
  `import org.apache.http.HttpEntity;
  
  import org.apache.http.HttpResponse;
  
  import org.apache.http.client.methods.HttpPost;
  
  import org.apache.http.impl.client.DefaultHttpClient;
  
  import org.json.JSONArray;
  
  
  import org.json.JSONObject;
  
  
  import android.annotation.SuppressLint;
  
  import android.app.Activity;
  
  import android.os.Bundle;
  
  import android.os.StrictMode;
  
  import android.util.Log;
  
  import android.widget.TextView;
  
  public class Test extends Activity {
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.news_single_post);
      StrictMode.enableDefaults();
      getData();
  }
  
  public void getData() {
      TextView textview = (TextView) findViewById(R.id.newsTitle);
      //TextView textview2 = (TextView) findViewById(R.id.content);
      //textview.setText("Why are you stubborn");
      InputStream isr = null;
      String result = "";
      String url = "http://192.168.1.1/vpl/getnews.php";
      try {
          DefaultHttpClient httpClient = new DefaultHttpClient();
          HttpPost httpPost = new HttpPost(url);
          HttpResponse httpResponse = httpClient.execute(httpPost);
          HttpEntity httpEntity = httpResponse.getEntity();
          isr = httpEntity.getContent();
          //textview2.setText("Test Passed");
      } catch (Exception e) {
          Log.e("log_tag", "Error in HTTP Connection" + e.toString());
          textview.setText("Connection Failed");
      }
  
      try {
          BufferedReader reader = new BufferedReader(new InputStreamReader(
                  isr, "iso-8859-1"), 8);
          StringBuilder sb = new StringBuilder();
          String line = null;
          while ((line = reader.readLine()) != null) {
  
              sb.append(line + "\n");
              //textview2.setText("Test Passed");
          }
  
          isr.close();
          result = sb.toString();
          //textview2.setText("Test Passed");
      } catch (Exception e) {
          Log.e("Buffer Error", "Error converting result " + e.toString());
          textview.setText("Buffer reader problem");
      }
  
      try {
  
          //String s = "";
          JSONArray jArray = new JSONArray(result);
  
          for (int i = 0; i &lt; jArray.length(); i++) {
              JSONObject json = jArray.getJSONObject(1);
  
              String newsTitle = json.getString("newsTitle");
              textview.setText(newsTitle);
              /*s = s + "Title: " + json.getString("newsTitle") + "\n"
                      + "Content: " + json.getString("newsContent") + "\n\n";
              textview.setText(s); */
          }
      } catch (Exception e) {
  
          Log.e("log_tag", "Error Parsing Data" + e.toString());
          textview.setText("Error in Parsing Data !!!!!");
      }
  
  }
  }
  </code></pre>