我正在尝试通过Android应用程序填充Postgres数据库。我正在使用Volley和Php将数据发送到Postgres数据库。通过浏览器可以很好地执行Post请求,即填充数据库,这可以通过chrome的Postman扩展名进行检查。但是,当我通过android执行此操作时,我将无法执行此操作。我也没有得到任何错误。请在将x和y post参数发送到URL的位置找到以下代码。submitbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() { @Override public void onResponse(String response) { builder.setTitle("Server Response"); builder.setMessage("Response: "+response); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Toast.makeText(Soil_Info.this, "Clear fields here", Toast.LENGTH_SHORT).show(); } }); AlertDialog alertDialog =builder.create(); alertDialog.show(); Toast.makeText(Soil_Info.this, "Successfull", Toast.LENGTH_SHORT).show(); } } , new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(Soil_Info.this, "Error Occured", Toast.LENGTH_SHORT).show(); error.printStackTrace(); } }){ @Override protected Map<String, String> getParams() throws AuthFailureError { Map <String,String> params=new HashMap<>(); params.put("x", "aisha"); params.put("y", "shah"); return params; } };
- 1 回答
- 0 关注
- 179 浏览
添加回答
举报
0/150
提交
取消