I have an error when trying to make a data modification to a web-service, I retrieve the data from a dialog box and then I recover the content, the content I recover it well, it does not arrive null.
the error is as follows:
The method I have in my class is the following:
@Override
public void onClickUpdate(final int position, final String identificador) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = this.getLayoutInflater();
View MyView = inflater.inflate(R.layout.dialog_signin_updatedonante, null);
final EditText identidad = (EditText)MyView.findViewById(R.id.identificador_tarea);
final EditText nombre_tarea = (EditText)MyView.findViewById(R.id.nombre_tarea);
final EditText nota = (EditText)MyView.findViewById(R.id.nota_tarea);
final EditText estudiante = (EditText)MyView.findViewById(R.id.estudiante_tarea);
identidad.setEnabled(false);
identidad.setText(identificador);
/* JSONObject jsonObject = new JSONObject();
try{
jsonObject.put("nombreUsuario",nombre_tarea.getText().toString()).put("nota",nota.getText().toString()).put("estudiante", estudiante.getText().toString());
}catch(JSONException e){
e.printStackTrace();
}*/
String ntarea = nombre_tarea.getText().toString();
String not = nota.getText().toString();
String estudi = estudiante.getText().toString();
final JSONObject jsonObject = new JSONObject();
try{
jsonObject.put("nombreUsuario", ntarea)
.put("nota", not)
.put("estudiante", estudi);
}catch(JSONException e){
e.printStackTrace();
}
final RequestQueue queue = Volley.newRequestQueue(getActivity());
builder.setView(MyView)
.setPositiveButton("Registrar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
if(nombre_tarea.getText().toString().equals("") || nota.getText().toString().equals("") || estudiante.getText().toString().equals("")){
Toast.makeText(getActivity(), "Porfavor llena todos los campos", Toast.LENGTH_LONG ).show();
}else{
String urlPut = "http://192.168.1.128:8080/WebServiceExamenFinal/webapi/tareas/";
JsonObjectRequest request = new JsonObjectRequest(Request.Method.PUT, urlPut + identificador, jsonObject,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(getActivity(), "Se envió correctamente", Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getActivity(), "Ocurrió un error al enviar la información"+error, Toast.LENGTH_LONG).show();
}
});
queue.add(request);
}
}
})
.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Toast.makeText(getActivity(),"No se actualizo ningun registro", Toast.LENGTH_SHORT).show();
alertDialog.dismiss();
}
});
alertDialog = builder.create();
alertDialog.show();
}
In the database does not register a null value, I enter blank records.