http://developer.android.com/reference/android/util/Base64.html
http://hi.baidu.com/xxfaxy/item/4c44f6fd4539dd5cc8f33705
首先导入包
import android.util.Base64;
String 变量=android.util.Base64.encodeToString(字符串.getBytes(),Base64.DEFAULT);
也可简写为
String 变量=Base64.encodeToString(字符串.getBytes(),Base64.DEFAULT);
至于解码
byte b[]=android.util.Base64.decode(字符串,Base64.DEFAULT);
String 变量=new String(b);
byte b[]=android.util.Base64.decode(字符串,Base64.DEFAULT);