借助Web服务在Android中显示数据

I am trying to display data in Android with the help of PHP web service, but I think some problems with my code so data is not displayed. I am giving here code of both file

Code of web service :

<?php
$dbhandle = mysql_connect($hostname, $username, $password,$datbase_name)
  or die("Unable to connect to
   MySQL");
$selected = mysql_select_db("code_Lessions",$dbhandle) 
or die("Could not select examples");
$final_data = array();
$query="SELECT * FROM LessionDetail"; 
if ($query_run = mysql_query($query)) 
    { 
        $i=0;
        while($query_row = mysql_fetch_assoc($query_run)) 
        { 
            $username = $query_row['LessionName']; 
            $password = $query_row ['CategoryName']; 
            $id = $query_row ['LessionId']; 
            //echo $username .'`s password is : '. $password.'<br>'; 
            $data = array('LessionId'=>$id , 'LessionName'=>$username ,'CategoryName'=>$password); 
            $final_data[$i]=$data;
            $i++;
            //print(json_encode($data)); 
            //print(json_encode($password)); 
        } 
        print(json_encode($final_data));
    }else{
     echo mysql_error(); 
    }
?>

File : JSONExampleActivity.java

package com.json.php;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;


public class JSONExampleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://code.guru99.com/android.php");
        TextView textView = (TextView)findViewById(R.id.textView1);
        try {
            HttpResponse response = httpclient.execute(httppost);
            String jsonResult = inputStreamToString(response.getEntity().getContent()).toString();
            JSONObject jObject = new JSONObject(jsonResult);
            JSONArray json = new JSONArray(jObject.getString(jsonResult));
            ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
            HashMap<String, String> map = new HashMap<String, String>();
            for(int i=0;i<json.length();i++){       
                /*map = new HashMap<String, String>();
                                JSONObject e = json.getJSONObject(i);
                                map.put("id",  String.valueOf(i));
                                map.put("name", "lname" + e.getString("name"));
                                map.put("Category", "Category: " +  e.getString("Category"));
                                mylist.add(map); 
                              System.out.println("The values are: " + map.values());*/
                JSONObject oneObject = json.getJSONObject(i);
                // Pulling items from the array
                String id = oneObject.getString("id");
                String name = oneObject.getString("name");
                String category = oneObject.getString("category");
                textView.setText(id + "-" + name + "-" + category);
                            }
        } 
        catch (JSONException e) {
            e.printStackTrace();
        } 
        catch (ClientProtocolException e) {
            e.printStackTrace();
        } 
        catch (IOException e) {
            e.printStackTrace();
        }


       }
    private JSONObject JSONObject(String jsonResult) {
        // TODO Auto-generated method stub
        return null;
    }
    private StringBuilder inputStreamToString(InputStream is) {
        String rLine = "";
        StringBuilder answer = new StringBuilder();
        BufferedReader rd = new BufferedReader(new InputStreamReader(is));

        try {
         while ((rLine = rd.readLine()) != null) {
          answer.append(rLine);
           }
        }

        catch (IOException e) {
            e.printStackTrace();
         }
        return answer;
       }
}

There are two records in my database and I want to display whole data from that table and nothing is displayed.

This is not a complete answer but you could use something like the following to help debug your code.

HttpResponse response = httpclient.execute(httppost);
        String jsonResult = inputStreamToString(response.getEntity().getContent()).toString();
Log.d("JSONDebug" , jsonResult);

This will display the input you are receiving in your log cat. So from there it will be easier to determine if the json is in the wring format or if the input to the reader is nothing at all, which i think is more likely the case since from your post it seems like you did not get a jsonParser error