0

am trying to save to save a fingerprint image which is a byte into mysql database from my android app.

 public void save(View view) {

    String id = efid.getText().toString().trim();

    String left_finger_image = new String(Left_Finger_Image);
    String right_finger_image = new String(Right_Finger_Image);
    String left_finger_iso = new String(Left_Finger_ISOTemplate);
    String right_finger_iso = new String(Right_Finger_ISOTemplate);

    if(!id.equals("")){
        StringRequest stringRequest = new StringRequest(Request.Method.POST, URL_SAVE_FINGERPRINT, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Log.d("res", response);
                if (response.equals("error")==false) {
                    Toast.makeText(Enrollment.this, "Fingerprint Enrolled Successfully..", Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(Enrollment.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                } else if (response.equals("failure")==true) {
                    Toast.makeText(Enrollment.this, "Fingerprint Enrolled Failed..", Toast.LENGTH_SHORT).show();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(Enrollment.this, error.toString().trim(), Toast.LENGTH_SHORT).show();
            }
        }){
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> data = new HashMap<>();
                data.put("fid", id);
                data.put("l_finger",left_finger_image);
                data.put("r_finger",right_finger_image);
                data.put("l_finger_iso",left_finger_iso);
                data.put("r_finger_iso",right_finger_iso);

                return data;

            }
        };
        RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
        requestQueue.add(stringRequest);
    }else{
        Toast.makeText(this, "Fields can not be empty!", Toast.LENGTH_SHORT).show();
    }
}
Jens
  • 67,715
  • 15
  • 98
  • 113
  • `a fingerprint image which is a byte` Impossible. One cannot put an image in a byte. – blackapps Oct 13 '22 at 06:40
  • disregard the question @blackapps, i mean how can some one store a byte into mysql database – sekwat isaac lisok Oct 13 '22 at 07:09
  • Then adapt the text of your post as it should immediately be clear for all at reading your post. So you wanna store onhe byte in a database? Then why talking about an image and all that code? I dont understand what you want. Please write a post that makes clear from the start what you want. – blackapps Oct 13 '22 at 07:20
  • Also there is no code that tries to put something in a database. – blackapps Oct 13 '22 at 07:26
  • `am trying to save to save a fingerprint image which is a byte into mysql database from my android app.` No. The code you posted maybe tries to upload binary data to a server. What the server would do with the binary data we dont know and is irrelevant looking at the code you posted. You have (on your Android device) an upload problem for binary data. Not a problem (on your server) to put binary data in a database. As said before: there is no code that tries to put something in a database. Know your problem! – blackapps Oct 13 '22 at 09:23
  • Before the server can put data in a database it should first receive the data. You have a data transfer problem. – blackapps Oct 13 '22 at 09:27

0 Answers0