I am new in Android development i just wanted to know how to send image through android REST web services and save it and retrieve from MySQL database
Asked
Active
Viewed 6,180 times
2 Answers
1
My experience, client send the image-string
(encoded Image byte array) to server and save it into the database.
To show the image, client get image-string
from server and decoded image-string
to byte array. Try to show image byte array
.
public static String encodeImage(byte[] imageByteArray) {
return Base64.encodeBase64URLSafeString(imageByteArray);
}
public static byte[] decodeImage(String imageDataString) {
return Base64.decodeBase64(imageDataString);
}
Use org.apache.commons.codec.binary.Base64

Zaw Than oo
- 9,651
- 13
- 83
- 131
-
can u show me the full code for sending to webservices and storing in database also. – Ajay Jul 29 '14 at 10:50
-
@Ajay, If u can convert image to `encoded string`, it is just like sending `Hello World` string to server. – Zaw Than oo Jul 29 '14 at 10:54
-
-
yes.. Can u tell me what datatype used for store the image? shall i use blob or VARCHAR(MAX).? – Ajay Jul 29 '14 at 11:05
-
@Ajay, How can I know you image size? That's why I cannot comment data type of database. It will be another topic. – Zaw Than oo Jul 29 '14 at 11:10
0
You can encode Bitmap image to Base64, so you will have an image encoded as string. You can use your REST API to send and save that string to database. Later when you want to display it, download and decode it to Bitmap again. Here is how you can do encoding/decoding.