0
//MyOpenHelper class 


public static final String TABLE_NAME2 = "Catlog_Chield";
db.execSQL("CREATE TABLE IF NOT EXISTS "+TABLE_NAME2+" (_id INTEGER PRIMARY KEY AUTOINCREMENT,log_desc TEXT,log_date TEXT,log_image BLOB,cat_id INTEGER,FOREIGN KEY (cat_id) REFERENCES "+TABLE_NAME1+"(_id))");

//My working class


 ByteArrayInputStream inputStream =   
    new ByteArrayInputStream(c.getBlob(c.getColumnIndex(log_image))); //Here I can't give my column name log_name
    Bitmap bp=BitmapFactory.decodeStream(inputStream);

    image.setImageBitmap(bp);
A_nto2
  • 1,106
  • 7
  • 16
Mohsin
  • 1

1 Answers1

0

Please try this way :

   byte[] image_bytes = c.getBlog(c.getColumnIndex(Here you need to give index));
   ByteArrayInputStream inputStream =   
   new ByteArrayInputStream(image_bytes); 
   Bitmap bp=BitmapFactory.decodeStream(inputStream);

// Now set the image using setImageBitmap method

moDev
  • 5,248
  • 4
  • 33
  • 63
  • I got exception Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 0 – Mohsin Jul 27 '12 at 12:16
  • Because right now cursor is at -1 index, you need to move the cursor to first row using its method. Like this if(c.moveToNext()){ then your code inside it} – moDev Jul 27 '12 at 14:52