java - Cannot parse data from the phpmyadmin -


i'm trying retrieve data phpmyadmin on android app ,but first want test through logcat see if works .when test ,i don't names of users in database sadly .

this showusers class :

package ie.example.artur.adminapp;  import android.content.intent; import android.os.bundle; import android.os.strictmode; import android.view.menu; import android.view.menuitem; import android.widget.arrayadapter; import android.widget.listview; import android.widget.toolbar; import android.os.asynctask; import android.os.bundle; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.support.v7.app.appcompatactivity;  import android.view.view;  import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.defaulthttpclient;  import java.io.bufferedreader; import java.io.inputstream; import java.io.inputstreamreader; import java.util.list;  /**  * created family on 24/07/2017.  */  public class showusers extends appcompatactivity {       listview lv;         string[] names = {"amy","john","joseph","carl"};         inputstream = null;     string line= null;     string result = null;        @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.showusers);          lv = (listview) findviewbyid(r.id.lv);          //inlfate list view items          lv.setadapter(new arrayadapter<string>(showusers.this,android.r.layout.simple_list_item_1,names));          android.widget.toolbar toolbar = (android.widget.toolbar) findviewbyid(r.id.toolbar);          strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build();         strictmode.setthreadpolicy(policy);          //set code fetch data database           try {             httpclient httpclient = new defaulthttpclient();              httppost httppost = new httppost("http://10.3.2.51/tut.php");              httpresponse response = httpclient.execute(httppost);             httpentity entity = response.getentity();             = entity.getcontent();             //setup inputstream receive data (initial)         }catch (exception e){             system.out.println("exception 1 caught");         }          try {              bufferedreader reader = new bufferedreader(new inputstreamreader(is,"iso-8859-1"),8);             // create string builder object hold data             stringbuilder sb = new stringbuilder();             while((line = reader.readline())!=null)                 sb.append(line+"\n");               //use tostring() method data in result              result = sb.tostring();                     is.close();             //check data printing results in logcat              system.out.println("-----here data -----");             system.out.println(result);          }catch(exception e){             system.out.print("exception 2 caught");         }        }     public boolean oncreateoptionsmenu(menu menu)     {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_main, menu);         return true;     }     @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         {             switch (item.getitemid())             {                 case r.id.action_settings : startactivity (new intent(this, showusers.class));                     break;             }             return super.onoptionsitemselected(item);         }}     } 

this setup tut.php file , location c:\xampp\www:

<?php  $con=mysql_connect("localhost","root",""); mysql_select_db("socialmedia_website",$con);  $r=mysql_query("select name users 1";  while($row=mysql_fetch_array($r))      {          $out[]=$row;     }      print(json_encode($out));     mysql_close($con) 

the table in phpyadmin :

enter image description here

this being outputted @ moment:

enter image description here

it should outputting users database


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -