【发布时间】:2011-06-12 04:33:08
【问题描述】:
我需要使用下面的代码将数据发布到 php 文件,该文件会将其保存在文本文件中。 我只是不知道如何创建 php 文件来接收下面的数据并将其保存在文本文件中。 尽可能简单。
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("stringData", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringData", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
String responseText = EntityUtils.toString(response.getEntity());
tv.setText(responseText);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
【问题讨论】: