Hi there I want to get data from a table through API using following query
select * from Order as O where username=O.username;
my Asyntask code is :
protected String doInBackground(Void... params) {
String data = "";
//login doesnt exist
final String url = Data.server + "/Order.aspx";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
List<NameValuePair> param = new ArrayList<NameValuePair>();
param.add(new BasicNameValuePair("username", mEmail));
UrlEncodedFormEntity uefa = null;
try {
uefa = new UrlEncodedFormEntity(param);
post.setEntity(uefa);
HttpResponse response;
response = client.execute(post);
HttpEntity entity = response.getEntity();
data = EntityUtils.toString(entity);
} catch (IOException e) {
// TODO Auto-generated catch block
data = e.toString();
e.printStackTrace();
}
return data;
}
@Override
protected void onPostExecute(String success) {
mAuthTask = null;
showProgress(false);
if (success.contains("[{") && (success.length() > 5)) {
//start the profile activity if json is returned
LocalRegistryreg(success);
try {
JSONArray jarr = new JSONArray(res);
ArrayAdapter<jarr> adapter = new ArrayAdapter<jarr>(this,
android.R.layout.simple_list_item_1, items);
scourseslist.setAdapter(adapter);
for (int i = 0; i < jarr.length(); ++i) {
// Extract values from JSON row:
JSONObject jsonObject = jarr.getJSONObject(i);
String PID = jsonObject.has("PID ") ? jsonObject.getString("PID ") : "";
String PTitle = jsonObject.has("PTitle ") ? jsonObject.getString("PTitle ") : "";
String Quantity = jsonObject.has("Quantity ") ? jsonObject.getString("Quantity ") : "";
String Price = jsonObject.has("Price ") ? jsonObject.getString("Price ") : "";
}
} catch (JSONException e) {
e.printStackTrace();
}
finish();
//Utility.shoAlert(success,LoginActivity.this);
} else {
Utility.shoAlert(success, Order.this);
}
}
im storing return json in a string variable String data;and my data look like this
and the data is multi row. i want to show up all my data row using listview. i treied but i got error. so kindly provide a piece of code to show my data in listview?