how to convert an image into base64 string in android?

Viewed 11969
Bitmap bm = BitmapFactory.decodeResource(getResources(),R.drawable.image);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object
    final String encodedImage = Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);

This is my code. It uploads the image onto the server. However, All I can see is a box. Where am I going wrong?

2 Answers
Related