Android アプリで edittext によって入力されたデータを送信する必要がありますが、サーバー側のコードを作成する方法がわかりません。私はPHP 5.3を使用しています。
2 に答える
0
クエリ文字列を使用してそれを行うことができます。ただし、そのためにはサーバー側の API が必要です。サーバー側でデータを送信するには、次のコードを使用できます:-
public String connect(String url)
{//for connect to database(QueryString API)
String userID = null;
HttpClient httpc = new DefaultHttpClient();
try
{
HttpPost post = new HttpPost(url);
HttpResponse response = httpc.execute(post);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
userID = EntityUtils.toString(response.getEntity());
Log.v("Login response", "" + userID);
}
}
catch (ClientProtocolException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
return userID;
}
public void abcd(String a1, String a2, String a3,
String a4, String a5) {
String QS ="";//acc. to ur data
String finalURL2 = url + QS;
String result2 = connect(finalURL2);
Log.v("message", result2);
}
于 2014-03-19T13:03:13.517 に答える