title: eclipse android string to Jsonarray
body: <p>I got the following of my android app:</p>
  
  <p>php file</p>
  
  <pre><code>&lt;?php
  $con=mysql_connect("localhost","root","");
  mysql_select_db("tutorial",$con);
  $r = mysql_query("select names from getdata where 1");
  while($row=mysql_fetch_array($r))
  {$out[]=$row;}
  print(json_encode($out));
  mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p>then i got the following:</p>
  
  <pre><code>[{"0":"Sam","names":"Sam"},{"0":"Peter","names":"Peter"},{"0":"Smith","names":"Smith"},{"0":"Alfred","names":"Alfred"}]
  </code></pre>
  
  <p>as STRING variable "result".</p>
  
  <p>i confirm that the app can connect and get the data.
  BUT ...</p>
  
  <pre><code>try{
              JSONArray jArray = new JSONArray(result);
              int count = jArray.length();
  
              for(int i=0; i&lt;count;i++){
                  JSONObject json_data = jArray.getJSONObject(i);
                  temp += json_data.getString("names")+ ":";
              }
              arr = temp.split(":");
              lv.setAdapter(new ArrayAdapter&lt;String&gt;(MainActivity.this,android.R.layout.simple_list_item_1, arr));
          }catch(Exception e){
              System.out.println("exception");
          }
  </code></pre>
  
  <p>this code keeps going to "exception"
  how can I solve it?
  Thanks a lot.</p>