因为我是初学者。谁能帮助我如何使用凌空方法将数据插入MySQL数据库?我应该尝试排球还是翻新?有人可以帮我举一些如何将数据添加到MySQL数据库的示例吗?
String Name,Email,Mobile,DOB;
final EditText name,email,mobile,dob;
Button insert;
name = (EditText) findViewById(R.id.name);
email = (EditText) findViewById(R.id.email);
mobile = (EditText) findViewById(R.id.mobile);
dob = (EditText) findViewById(R.id.dob);
insert = (Button) findViewById(R.id.insert);
insert.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Name = name.getText().toString();
Email = email.getText().toString();
Mobile = mobile.getText().toString();
DOB = dob.getText().toString();
insertdb();
}
private void insertdb() {
final TextView textView = (TextView) findViewById(R.id.text);
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
String url ="http://ganeshkumar.epizy.com/insertdb.php?
name="+Name+"&email="+Email+"&mobile="+Mobile+"&dob="+DOB;
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// Display the first 500 characters of the response string.
textView.setText("Response is: "+ response.substring(0,500)); Toast.makeText(getApplicationContext(),"Success",Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
textView.setText("That didn't work!"); Toast.makeText(getApplicationContext(),"Failed",Toast.LENGTH_LONG).show();
}
});
// Add the request to the RequestQueue.
queue.add(stringRequest);
}
});
我实际上不知道如何将分配给String的数据发送到PHP