我已經寫了這個代碼發送數據到服務器。它在沒有報告任何錯誤的情況下運行,但是當提交按鈕被按下時,它會出來並且不存儲數據。你能幫我嗎?哪裏有問題?不存儲數據,並沒有output.in android
public void onClick(View v) {
String name=""+etname.getText().toString();
String age=""+etage.getText().toString();
String email=""+etemail.getText().toString();
List<Pair<String, String>> params = new ArrayList<>();
params.add(new Pair<>("name", name));
params.add(new Pair<>("age", age));
params.add(new Pair<>("email", email));
try {
URL url = new URL("http://127.0.0.1/tutorials.php");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
urlConnection.connect();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
in=urlConnection.getInputStream();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
你在哪裏將數據刷新到服務器?你只需打開一個連接到服務器..請閱讀下面的例子閱讀/寫入https://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html –