0
byte[] imageInByte;
ImageView iViewAddImage;

if (imageInByte.length>0) {
   Bitmap bitmap = BitmapFactory.decodeByteArray(imageInByte, 0, imageInByte.length);
   iViewAddImage.setImageBitmap(bitmap);
 }

I am getting the Bitmap value null and imageInByte.length=20621.

What am doing wrong. Sugesst me ?

EDIT 1 :

public void insertImage(byte[] imageInByte2) 
{
    if(sqliteDb != null)
    {
        try {
             sqliteDb.insert("database",null,getDataValues(imageInByte2));
        } catch(Exception e) {
            e.printStackTrace();
        }
    }   
}

   private ContentValues getDataValues(byte[] imageInByte2){
    ContentValues contentValues = new ContentValues();

    try {
        contentValues.put("image",imageInByte2);

    } 
    catch (Exception e) {
        e.printStackTrace();
    }   
    return contentValues;
  }
Akarsh M
  • 1,629
  • 2
  • 24
  • 47

1 Answers1

0

this might help you

byte imageinbyte[];
bitmap bmp;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
                bmp.compress(Bitmap.CompressFormat.JPEG, 100, bos);
                imageInByte = bos.toByteArray();

You can directly set image view background

ImageView.setImageBitmap(bmp);|
Android Noob
  • 621
  • 8
  • 18