I have the current application which sends and retrieves data from a MySQL database but the information so far I was transferring was String. How can I update the code below
If you want to send Image on Server! You have to change it in Base 64 string.
For saving it in Database! You have to convert it in Blob type!
try this code:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); //compress to which format you want.
byte [] byte_arr = stream.toByteArray();
String image_str = Base64.encodeToString(byte_arr, Base64.DEFAULT);
And pass this as a parameter just like you are adding other parameters in request!
params.add(new BasicNameValuePair("image",image_str));
I hope this will help! See this link for further detail.