-3

i'm beginner in android and i want to get data from server and show the data into list view. i get correctly data from server and show result into Toast,but my data is:

[
    {"countryname":"China", "Count":"200"}

]

how can i parse that result in the this block?
for example:countryname=China

 @Override

protected void onPostExecute(String result) {
    //Toast.makeText(getBaseContext(), "Data Sent!", Toast.LENGTH_LONG).show();
    //Log.d("My Return BackUp is:",result.toString());
    try {
        JSONObject jsonObj = new JSONObject(result);




    } catch (JSONException e) {
        e.printStackTrace();
    }


}

please do not show me a link of tutorial or another site,.please write your code. thanks for all.

behzad razzaqi
  • 93
  • 2
  • 10
  • "please write your code" -> No. Please write your own code and come back with your issues... – 2Dee Mar 16 '15 at 13:45
  • possible duplicate of [How to parse JSON in Android](http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android) – 2Dee Mar 16 '15 at 13:45

1 Answers1

0
protected void onPostExecute(String result) {
    //Toast.makeText(getBaseContext(), "Data Sent!", Toast.LENGTH_LONG).show();
    //Log.d("My Return BackUp is:",result.toString());
    try {
        JSONArray jsonArray = new JSONArray(result);
        for(int i=0;i<jsonArray.length();i++)
          {
          JSONObject jsonObj =jsonArray.getJSONObject(i);
          String country=jsonObj.getString("countryname");
          String count=jsonObj.getString("Count");
          }
    } catch (JSONException e) {
        e.printStackTrace();
    }


}
Akash Jindal
  • 505
  • 3
  • 7