Reputation: 698
How to put data from database table in listView
using Android code.
This is PHP code, I need Android code for this:
$your_querry="select * from member ";
$query=mysql_query($your_querry);
$list=array();
while($row=mysql_fetch_assoc($query))
{
$list[]=$row;
}
echo json_encode($list);
Upvotes: 2
Views: 1031
Reputation: 271
for this question use JSONParser.java and ListAdapter.java ,
if your listview contain image I strongly recommend to you use
1-MemoryCache.java.
2-FileCache.java.
3-ImageLoader.java.
4-Utils.java.
that's all I think
Upvotes: 3
Reputation: 6363
Try something like this
DefaultHttpClient httpclient = new DefaultHttpClient(new BasicHttpParams());
HttpGet httppost = new HttpGet("path/to/your/php-script");
httpGet.setHeader("Content-type", "application/json");
InputStream inputStream = null;
String result = null;
try {
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();
// Now parse the JSON with some JSON library like Jackson, Gson or JSON.org
...
// Then fill the listView with the objects you parsed
...
Upvotes: 1