I want to get the image file from php. In my case I tried to convert image into BLOB first then cast it back after I get it from JSONObject. It says in Logcat that JSONObject can not be cast to java.sql.Blob.
If there is another way please tell.
Here is my code:
JSONArray array = new JSONArray(getJSONUrl(url));
for (int i = 0; i < products.length(); i++) {
JSONObject jsonObj = products.getJSONObject(i);
placeName = jsonObj.getString(TAG_PlaceName);
placeDesc = jsonObj.getString(TAG_PlaceDesc);
placeID = jsonObj.getString(TAG_PlaceID);
try {
Blob blob = (Blob) jsonObj.get(TAG_placeIcon);
byte[] byteBlob = blob.getBytes(0,
(int) blob.length());
Bitmap bmp = BitmapFactory.decodeByteArray(byteBlob, 0,
byteBlob.length);
rowItems.add(new RowItem(placeID,placeName,placeDesc,bmp));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}