Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import android.util.Base64; import java.io.ByteArrayOutputStream; public class Main { public static String encodeToString(Bitmap bitmap) { if (bitmap == null) { return ""; } return Base64.encodeToString(encodeToBytes(bitmap), Base64.DEFAULT); } public static byte[] encodeToBytes(Bitmap bitmap) { if (bitmap == null) { return null; } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); return byteArrayOutputStream.toByteArray(); } }