In my Application, I need to convert Image to Base64 format. Could anyone please let me know how can I do that?
Please forward your valuable suggestions.
Thanks in advance :)
In my Application, I need to convert Image to Base64 format. Could anyone please let me know how can I do that?
Please forward your valuable suggestions.
Thanks in advance :)
Android has a class for doing this.
http://developer.android.com/reference/android/util/Base64.html
You can use the Base64 Android class:
String encodedImage = Base64.encodeToString(byteArrayImage, Base64.DEFAULT);
You'll have to convert your image into a byte array though. Here's an example:
Bitmap bm = BitmapFactory.decodeFile("/path/to/image.jpg");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object
byte[] b = baos.toByteArray();
This question has already been asked before..
You can try using this class to encode or decode base64 String