Sahil Jain Sahil Jain - 1 year ago 98
Android Question

How to get URL for an image stored in database in BLOB format

I'm saving image in wamp database. How to get it's URL so that I can use that URL in my android program for displaying that image?

Answer Source
  public Bitmap getCurrentBitmap() {
        SQLiteDatabase db       =   dbs.getWritableDatabase();
        String sql              =   "SELECT * FROM Image";// SELECT blob image column.
        Cursor cursor           =   db.rawQuery(sql, new String[]{});
        Bitmap bmp=null;
            //this.accId             = cursor.getInt(0);
          //  this.accName           = cursor.getString(1);
            byte[] logoImage       = cursor.getBlob(1);// get blob image convert into byte array[]

         Bitmap    bmp = BitmapFactory.decodeByteArray(logoImage, 0, logoImage.length);// now convert into Bitmap
        if (cursor != null && !cursor.isClosed()) {
        if(cursor.getCount() == 0){
            return null;
        } else {
            return bmp;

// To show images

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download