android - Retrive image format from byte format : show null value -


enter image description here image of data base can see here image insert in byte format. structure of database

public void oncreate(sqlitedatabase db) {      final string[] creatstatments = new string[]{"create table "             + image_handler             + "(_id integer primary key autoincrement,"+ image_handeler_column+" blob)"  }; 

i using following code retrieve image database

          system.out.println(" satrt image rertrive");         cursor = dh.rawquery("select _id, image_byte image_database",null);                 int i=0;         if (cursor.movetofirst()) {             {                    string str_cursor =cursor.getstring(1);                    system.out.println("string value of cursor"+str_cursor);                 //   data array,or class variable                    bb = cursor.getblob(cursor.getcolumnindex(databasehelper.image_handeler_column));                 system.out.println("byte array value"+bb);             i++;               } while (cursor.movetonext());             bitmap bmp=bitmapfactory.decodebytearray(bb,0,bb.length);             system.out.println("bitmap value"+bmp);               imageview.setimagebitmap(bmp);          } 

while working on above code value of byte array value showing b@405889a8 me , bmp ( bitmap )value null me. why getting bmp value null . going update question. inserting image in database url using following code

         static private bitmap downloadbitmap(string url) throws ioexception {     httpurirequest request = new httpget(url);     httpclient httpclient = new defaulthttpclient();     httpresponse response = httpclient.execute(request);      statusline statusline = response.getstatusline();     int statuscode = statusline.getstatuscode();       if (statuscode == 200) {         system.out.println("kjklcmklxc");       httpentity entity = response.getentity();       byte[] bytes = entityutils.tobytearray(entity);        bitmap bitmap = bitmapfactory.decodebytearray(bytes, 0,           bytes.length);       bitmap.compress(bitmap.compressformat.jpeg, 40, byt_aary_outpt_strm);     dh.delete(databasehelper.image_handler, null, null);       bitmapdata = byt_aary_outpt_strm.tobytearray();       system.out.println("bitmap of image converted image");       for(int =0 ; i<bitmapdata.length;i++){           convert_save_byte_str = convert_save_byte_str+bitmapdata[i];       }       system.out.println("njdsfnh"+convert_save_byte_str);       contentvalues userdetailvalues = new contentvalues();          userdetailvalues.put("image_byte", convert_save_byte_str);         system.out.println("between put , insert");         dh.insert(databasehelper.image_handler, null, userdetailvalues);          cursor = dh.rawquery("select _id, image_byte image_database",null);         int i=0;         if (cursor.movetofirst()) {             {                  //   data array,or class variable                    bb = cursor.getblob(cursor.getcolumnindex(databasehelper.image_handeler_column));                 //system.out.println("productid"+data);                 //intent.putextra("product_id", data);                 system.out.print("bytengkfgkjgk"+bb[i]);              i++;             } while (cursor.movetonext());         }        return bitmap;         } else {       throw new ioexception("download failed, http response code "           + statuscode + " - " + statusline.getreasonphrase());     }   } 


Comments