Note that there are some explanatory texts on larger screens.

plurals
  1. POError in the LogCat: Error to popular data org.json.JSONException: value i>>? of tpe java.lang.String cannot be converted to JSONArray
    primarykey
    data
    text
    <p>I'm trying to convert a String [] json to a query on an external server and display in a listview</p> <pre><code>public class ConectPhp extends ListActivity { public static InputStream inpString = null; String result = ""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ArrayList&lt;NameValuePair&gt; parametros = new ArrayList&lt;NameValuePair&gt;(); parametros.add(new BasicNameValuePair("DATA", "2011-11-05")); try{ HttpClient httpcliente = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://192.168.254.254/mobile/ConexaoWcrm.php/"); httppost.setEntity(new UrlEncodedFormEntity(parametros)); HttpResponse response = httpcliente.execute(httppost); HttpEntity entity = response.getEntity(); inpString = entity.getContent(); } catch (Exception e){ Log.e("log_tag", "Error to conect a "+e.toString()); } </code></pre> <p>//convert a return in string</p> <pre><code> try{ BufferedReader reader = new BufferedReader(new InputStreamReader(inpString, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while((line = reader.readLine()) != null){ sb.append(line+"\n"); } inpString.close(); result=sb.toString(); }catch (Exception e){ Log.e("log_tag","Error to convert result"+e.toString()); } </code></pre> <p>//Here will pass the data to json, but not sure how to do it, then store in the listview.</p> <pre><code>try{ JSONArray jArray = new JSONArray(result); String[] clientes = new String[jArray.length()]; for(int i=0; i&lt;jArray.length();i++){ JSONObject json_data = jArray.getJSONObject(i); clientes[i]=json_data.getString("clientnome"); } this.setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, clientes)); }catch(Exception e){ Log.e("log_tag","Error popular data "+e.toString()); } </code></pre> <p>I'm new, and already with this difficult project, if they have any tips to give me will also be accepted, must list certain data bank for external listview.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload