如何将 ArrayList<> 转换为字符串 ...
细节:
step1:发送电子邮件地址到 php mySql 数据库 step2:如果电子邮件地址与数据库内容匹配,则回显成功 step3:检索 php 回显值(“success”) step4:将响应分配给字符串 phpEchoedVal step5:比较 phpEchoedVal 与“成功” step6:将电子邮件写入 sd 卡
这个可以吗//url = 电子邮件地址
ArrayList nameValuePair = new ArrayList(1);
nameValuePair.add(new BasicNameValuePair("url", url));
try {
//open an httpclient connection
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(strLink);
httppost.setEntity(new UrlEncodedFormEntity(data));
//response retrieve "success" echoed from server
ResponseHandler<String> handleResponse = new BasicResponseHandler();
//converts server response to string.
String phpEchoVal = httpclient.execute(httppost, handleResponse);
txtInfo.setText(phpEchoVal);
String containEmail = txtInfo.getText().toString();
//compare response from server with local string
// if successful write email to sd card
if ((containEmail.equals("success"))){
//create a new text file
File myFile = new File("/sdcard/moLarouteReg.txt");
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
myOutWriter.append(containEmail);
//close writer
myOutWriter.close();
fOut.close();
//Open menu
Intent openMenu = new Intent("com.molaroute.mu.Menu");
startActivity(openMenu);
finish();
Log.d("test","fileWritten: "+myOutWriter);
}else {
...
}
}