title: convert json object to string and display
body: <p>Basically here im using url connection to connect to php, everything is work find in log in and register phase, now i want to fetch the json object that i create in php file and then display it in a string view, so anyone got idea regarding this?</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_display);
  
      dataField = (TextView) findViewById(R.id.data);
      btnDis = (Button) findViewById(R.id.btnClick);
  
  
  
  
      btnDis.setOnClickListener (new View.OnClickListener(){
          @Override
          public void onClick(View v){
  
              strUrl ="http://10.0.2.2/android/display.php";
  
              new jsonParse().execute();
          }
      });
  }
  
  
  
  
  public class jsonParse extends AsyncTask&lt;String, String, String&gt;{
      @Override
      protected void onPreExecute() {
  
          super.onPreExecute();
  
      }
  
      @Override
      protected void onPostExecute(String s) {
  
          Toast.makeText(EditActivity.this,""+result,Toast.LENGTH_LONG ).show();
      }
  
      @Override
      protected String doInBackground(String... params) {
          try{
              URL url = new URL (strUrl);
              HttpURLConnection con = (HttpURLConnection) url.openConnection();
              con.setRequestMethod("POST");
              con.connect();
  
              //get response from server
              BufferedReader bf = new BufferedReader(new InputStreamReader(con.getInputStream()));
              String value = bf.readLine();
              System.out.println("result is"+value);
              result = value;
  
              String finalJson = bf.toString();
              JSONObject parentObject = new JSONObject(finalJson);
              JSONArray parentArray = parentObject.getJSONArray("data");
  
              JSONObject finalObject= parentArray.getJSONObject(0);
              String username = finalObject.getString("NAME");
              String age = finalObject.getString("AGE");
              String result = username +" - "+age;
              return result;
          }
  
  
          catch(Exception e){
              System.out.println(e);
          }
  
          return null;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my php file called display.php</p>
  
  <pre><code>&lt;?php
  require "conn.php";
  require_once "global.php";
  
  
  
  //get record from databases
  $query = "SELECT * FROM user";
  if($result = mysqli_query($conn, $query)){
    // printf("%d", mysqli_num_rows($result));
  
  if(mysqli_num_rows($result) &gt; 0){
    $status = 'true';
    $message = 'data retrieved successfully';
        while($row = mysqli_fetch_assoc($result)){
          $name = $row['name'];
          $age = $row['age'];
          $username = $row['username'];
  
  
          // echo $name."\n\n";
          // echo $age."\n\n";
          // echo $username."\n\n";
  
          $data .= '{"NAME" : "'.$name.'", "AGE" : "'.$age.'", "USERNAME" : "'.$username.'"},';
        }
  
  }else{
    $status = 'false';
    $message = 'data retrieved failed';
    $data = '';
  }
  
  mysqli_free_result($result);
  mysqli_close($conn);
  }else{
    $message = mysqli_error($conn);
  }
  $output = '{"status": "'.$status.'","message":"'.$message.'", "data": ['.rtrim($data, ',').']}';
  echo $output;
  
  ?&gt;
  </code></pre>