Java tutorial
//package com.java2s; import android.util.Base64; import java.io.UnsupportedEncodingException; public class Main { public final static String ENCODING = "UTF-8"; public static String encoded(String data) throws UnsupportedEncodingException { // byte[] b = Base64.encodeBase64(data.getBytes(ENCODING)); byte[] b = Base64.encode(data.getBytes(ENCODING), Base64.DEFAULT); return new String(b, ENCODING); } }