I am trying to post my phone contact details like name,number,email,address and photo to the webserver in json fromat,where the image is encoded in Base64 format. In server side the image is being stored as BLOB type in the database. I'm trying to retreive and display all the data from the server in a listview. I am able to display all data except image.
Here is the code:
For Encoding the image:
ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, COMPRESSION_QUALITY, byteArrayBitmapStream);
byte[] b = byteArrayBitmapStream.toByteArray();
String encodedImage = Base64.encodeToString(b, Base64.DEFAULT);
jsonObject.accumulate("imageData",encodedImage);
For Decoding the image:
String image=(String)jsonObject.get("image");
byte[] byteArray = Base64.decode(jsonObject.getString("imageData").getBytes(), Base64.DEFAULT) ;
Bitmap bmp1 = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put(TAG_IMAGE,bmp1);
Please help me out to display the image in listview.Thanks...
Error Log:
12-16 12:07:58.403: E/BitmapFactory(1072): Unable to decode stream: java.io.FileNotFoundException: /android.graphics.Bitmap@40f67ac0: open failed: ENOENT (No such file or directory)
12-16 12:07:58.423: I/System.out(1072): resolveUri failed on bad bitmap uri: android.graphics.Bitmap@40f67ac0