Java tutorial
//package com.java2s; import android.util.Base64; import android.util.Base64DataException; import java.io.UnsupportedEncodingException; public class Main { public static String encodeBase64(String str) throws UnsupportedEncodingException, Base64DataException { return Base64.encodeToString(str.getBytes("UTF-8"), Base64.DEFAULT).replace("\n", ""); } }