title: JSON array returned from php script loops incorrectly
body: <p>I've been working on a bit of code for a bigger project to populate a listview in Android. Long story short i can only get the emulator to go loop over the first item in the JsonArray, even though i know the result returned from my php script contains 3 sets of data.</p>
  
  <p>Here is my Code:</p>
  
  <pre><code>public void getChosen(String username) {
      String chosenFriend,msg,type,holder;
      Bitmap profilepic;
          try {
              // Creating HTTP Post
              HttpPost httppost = new HttpPost(
              "mysite/chosenlist.php");
              // Builds post parameters key and value pair
              List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
              nameValuePairs.add(new BasicNameValuePair("username", username));
              // Url Encoding the POST parameters
              httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
              // Making HTTP Request
              HttpResponse response = httpclient.execute(httppost);
              HttpEntity entity = response.getEntity();
              is = entity.getContent();
  
          }
  
          catch (Exception e) {
              // writing error to Log
              e.printStackTrace();
              //return null;
  
          }
          try {
  
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              sb = new StringBuilder();
              sb.append(reader.readLine() + "\n");
              String line = "0";
  
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
  
              is.close();
              result = sb.toString();
              System.out.println(result);
  
          } catch (Exception e) {
              // writing error to Log
              e.printStackTrace();
              //return null;
  
          }
          try {
              jArray = new JSONArray(result);
              JSONObject json_data=null;
              int jAL = jArray.length();
  
              for(int i=0;i&lt;jAL;i++){
                   json_data = jArray.getJSONObject(i);
  
  
                  System.out.println(json_data);
                   chosenrow cr = new chosenrow();
                   holder = json_data.getString("Sender");
  
  
                   if(json_data.getString("Type").contentEquals("1")){
                   if (holder.equalsIgnoreCase(username)){
                       cr.setUser(json_data.getString("Reciever")); 
                       chosenFriend = json_data.getString("Reciever");
                       System.out.println(chosenFriend);
                   }
                   else{
                       cr.setUser(json_data.getString("Sender")); 
                       chosenFriend = json_data.getString("Sender");
                   }
                   type = json_data.getString("Type");
                   cr.setStatus(type);
  
                   msg = getLastMsg(chosenFriend);
                   cr.setLastMsg(msg);
                   String time = getLastMsgTime(chosenFriend);
                   cr.setTime(time);
                   profilepic = getPicture(chosenFriend);
                   cr.setPic(profilepic);
                   chosen.add(cr);             
                  System.out.println(cr);
                   }
                   else{
                       if (holder.equalsIgnoreCase(username)){
                           cr.setUser(json_data.getString("Reciever")); 
                           chosenFriend = json_data.getString("Reciever");
                           System.out.println(chosenFriend);
                       }
                       else{
                           cr.setUser(json_data.getString("Sender")); 
                           chosenFriend = json_data.getString("Sender");
                       }
                       type = json_data.getString("Type");
                       cr.setStatus(type);
  
                       msg = "Pending";
                       cr.setLastMsg(msg);
                       String time = "Awaiting Request Response";
                       cr.setTime(time);
                       profilepic = getPicture(chosenFriend);
                       cr.setPic(profilepic);
                       chosen.add(cr);             
  
  
                   }
              }
  
          } catch (Exception e) {
              // writing error to Log
              e.printStackTrace();
              //return null;
  
          }
  
  
  
  
      }
  </code></pre>
  
  <p>Any Clue as to why i cannot loop beyond the first item in the array?</p>
  
  <p>Thanks.</p>