Base64中的FileNotFound异常到位图Android解码

时间:2015-03-25 16:55:16

标签: android bitmap base64 filenotfoundexception

首先,我在androidManifest.xml上添加了permisions:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

我试图用这段代码解码base64字符串:

private Bitmap decodeImage(String image_data) {
        // Decode the encoded string into largeIcon
        Bitmap largeIcon = null;
        if ((image_data != null) && (!image_data.equals(""))) {
            byte[] decodedImage = Base64.decode(image_data, Base64.DEFAULT);
            if (decodedImage != null) {
                largeIcon = BitmapFactory.decodeByteArray(decodedImage
                        , 0
                        , decodedImage.length);
            }
        }
        return largeIcon;
   }

但总是有同样的问题:

E/BitmapFactory(10601): Unable to decode stream: java.io.FileNotFoundException: /9j/4AAQSkZJRgABAQEASABIAAD/gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsND (BLA BLA BLA) now/ud/p/9k=: open failed: ENOENT (No such file or directory)

我从本地数据库获取base64字符串,用于运行应用程序的Android是4.4.2

我不知道问题出在哪里!欢迎任何帮助。

由于

0 个答案:

没有答案