Base64 encoder and decoder

Is there a base-64 decoder and encoder for a String in Android?


See android.util.Base64

It seems that this was added in API version 8 or android 2.2 so it will not be available on the older platforms.

But the source of it is at android/util/ so if needed one could just copy it unchanged for older versions.

This is an example of how to use the Base64 class to encode and decode a simple String value.

// String to be encoded with Base64
String text = "Test";
// Sending side
byte[] data = null;
try {
    data = text.getBytes("UTF-8");
} catch (UnsupportedEncodingException e1) {
String base64 = Base64.encodeToString(data, Base64.DEFAULT);

// Receiving side
byte[] data1 = Base64.decode(base64, Base64.DEFAULT);
String text1 = null;
try {
    text1 = new String(data1, "UTF-8");
} catch (UnsupportedEncodingException e) {

This excerpt can be included in an Android activity.

Need Your Help

Accessing Resource Files in a Test Method unit-testing

Iam writing a test method (in a .Net Test Project) and i need to access a resorce file that is in another Project of the Solution.

Mapping not working when creating a model with Ext.create?

extjs extjs4.2

When I create a model using Ext.create() in ExtJs 4.2+, I am expecting the mapping to fill the model but it does not seem to do it. Is it a normal behavior?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.