Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util.Base64; import java.io.*; public class Main { public static String openAsBase64(String imgPath) { Bitmap photo = BitmapFactory.decodeFile(imgPath); ByteArrayOutputStream baos = new ByteArrayOutputStream(); photo.compress(Bitmap.CompressFormat.JPEG, 85, baos); byte[] b = baos.toByteArray(); photo.recycle(); return Base64.encodeToString(b, Base64.DEFAULT); } }