您好先生,我想将数据列表发送到 php 服务器我使用以下代码是否正确请告诉我
i try this code
ArrayList<String>list1=new ArrayList<String>();
for(int i=0;i<json.length();i++)
{
JSONObject e = json.getJSONObject(i);
list1.add(e.getString("menuname"));
}
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("menuname",list1.toString()));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.0.103/update.php");
// "http://192.168.1.12/addnotes.php");
//url+"Notes/addnotes.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
Toast.makeText(getApplicationContext(),
"Saved Sucessfully", Toast.LENGTH_SHORT).show()
请看上面的代码是否正确..请告诉我