Java tutorial
//package com.java2s; import android.util.Base64; import java.io.UnsupportedEncodingException; public class Main { /** * Encodes a string with Base64 * * @param input String to be encoded * @return Base64 encoded input * @throws UnsupportedEncodingException */ public static String encodeBase64(String input) throws UnsupportedEncodingException { byte[] data = input.getBytes("UTF-8"); return Base64.encodeToString(data, Base64.DEFAULT); } }