开发者

Do I need an external package for decoding Base 64 in Android?

I am currently working on an Android project in which I need to 开发者_运维问答extract an image from a database. The image is saved in Base 64 code, and the datatype in the table is BLOB.

I have read about decoding Base 64, and now I am uncertain if I need an external package (for example, org.apache.commons.codec.binary) or is it now included since api 8 (from link: How to use Base64 (included in android since api 8 (2.2)) in a android project api 3 (android 1.5)?)?

What is the best way to do this?


Since API level 8 (Android 2.2), there is the following class:

https://developer.android.com/reference/android/util/Base64.html

or

https://developer.android.com/reference/android/util/Base64InputStream.html

If you're targetting a lower SDK version, then I'd recommend using the class found there: http://androidcodemonkey.blogspot.com/2010/03/how-to-base64-encode-decode-android.html


If you're app is targeting only OS2.2 and later, then you can use the Base64 class (android.util.Base64).

Otherwise, as the link you included suggests, you'll have to include your own Base64 class to handle earlier OS versions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜