i build android 4.0 apps with a cart handle a bunch of selection stored in data/data/.../cartlist.db and need to know how to related the cursor result with List NameValuePair, here is my activity
** public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sendorder);\[code\] postData(); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); String[] columns = new String[] { "_id","name", "qty", "price" }; Cursor messagesCursor= getContentResolver().query( MyContentProvider.CONTENT_URI, columns, null, null, null); int theTotal = messagesCursor.getCount(); Toast.makeText(this, "Total6: " + theTotal, Toast.LENGTH_LONG).show(); int idCol = messagesCursor.getColumnIndex("_id"); int nameCol = messagesCursor.getColumnIndex("name"); int qtyCol = messagesCursor.getColumnIndex("qty"); int priceCol = messagesCursor.getColumnIndex("price"); while (messagesCursor.moveToNext()) { columns[0] = Integer.toString((messagesCursor.getInt(idCol))); quantity = messagesCursor.getString(nameCol); product = messagesCursor.getString(qtyCol); cost = messagesCursor.getString(priceCol); } } public void postData() { // Creating HTTP client HttpClient httpClient = new DefaultHttpClient(); // Creating HTTP Post HttpPost httpPost = new HttpPost( "http://example.com/droid/order.php"); // Building post parameters // key and value pair List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(); nameValuePair.add(new BasicNameValuePair("qty", quantity)); nameValuePair.add(new BasicNameValuePair("product",product)); nameValuePair.add(new BasicNameValuePair("price",cost)); // Url Encoding the POST parameters try { httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair)); } catch (UnsupportedEncodingException e) { // writing error to Log e.printStackTrace(); } // Making HTTP Request try { HttpResponse response = httpClient.execute(httpPost); // writing response to log Log.d("Http Response:", response.toString()); } catch (ClientProtocolException e) { // writing exception to log e.printStackTrace(); } catch (IOException e) { // writing exception to log e.printStackTrace(); } }\[/code\]
** public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sendorder);\[code\] postData(); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); String[] columns = new String[] { "_id","name", "qty", "price" }; Cursor messagesCursor= getContentResolver().query( MyContentProvider.CONTENT_URI, columns, null, null, null); int theTotal = messagesCursor.getCount(); Toast.makeText(this, "Total6: " + theTotal, Toast.LENGTH_LONG).show(); int idCol = messagesCursor.getColumnIndex("_id"); int nameCol = messagesCursor.getColumnIndex("name"); int qtyCol = messagesCursor.getColumnIndex("qty"); int priceCol = messagesCursor.getColumnIndex("price"); while (messagesCursor.moveToNext()) { columns[0] = Integer.toString((messagesCursor.getInt(idCol))); quantity = messagesCursor.getString(nameCol); product = messagesCursor.getString(qtyCol); cost = messagesCursor.getString(priceCol); } } public void postData() { // Creating HTTP client HttpClient httpClient = new DefaultHttpClient(); // Creating HTTP Post HttpPost httpPost = new HttpPost( "http://example.com/droid/order.php"); // Building post parameters // key and value pair List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(); nameValuePair.add(new BasicNameValuePair("qty", quantity)); nameValuePair.add(new BasicNameValuePair("product",product)); nameValuePair.add(new BasicNameValuePair("price",cost)); // Url Encoding the POST parameters try { httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair)); } catch (UnsupportedEncodingException e) { // writing error to Log e.printStackTrace(); } // Making HTTP Request try { HttpResponse response = httpClient.execute(httpPost); // writing response to log Log.d("Http Response:", response.toString()); } catch (ClientProtocolException e) { // writing exception to log e.printStackTrace(); } catch (IOException e) { // writing exception to log e.printStackTrace(); } }\[/code\]