File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes [TUTORIAL] How to base64 encode decode Android Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "[TUTORIAL] How to base64 encode decode Android" Watch "[TUTORIAL] How to base64 encode decode Android" New topic

[TUTORIAL] How to base64 encode decode Android

Greg Zimmers

Joined: Feb 04, 2010
Posts: 4
The official documentation states that base64 encode and decode in Android is in the Android.util package. But when you go to use it you will find it's not there!

After much searching, I confirmation Android left base64 encode and decode out of the Android.util package. So what to do? Don't worry, Robert W. Harder has but together a very fast Base64 encoding and decoding class you can include in your project (thanks Robert!). Here is how to add base64 encode and decode to your project.

Step 1. Visit Robert's website and download the class file.

Step 2. The zip file you downloaded in step 1 includes the base64 class and a folder with examples and documentation.

Step 3. Copy the class file into your project. Copy into your appropriate "src" folder.

Step 4. Refresh your project so the new file is included.

Step 5. When the file is included in your project, you will get the following error "The declared package does not match the expected package". Fix this by opening the class file and adding a package declaration that matches your project.

Step 6. Done. Your ready to base64 encode and decode.

Android Code Monkey
Monu Tripathi

Joined: Oct 12, 2008
Posts: 1369

thanks for posting this...

[List of FAQs] | [Android FAQ] | [Samuh Varta]
I agree. Here's the link:
subject: [TUTORIAL] How to base64 encode decode Android
It's not a secret anymore!