Convert Drawable to BLOB Datatype

后端 未结 3 1262
执念已碎
执念已碎 2020-12-06 03:32
public Drawable icon; \\\\ Some value in this field

I am creating a database in SQLite Manager. I want to store icon into the database

3条回答
  •  -上瘾入骨i
    2020-12-06 04:13

    I made few changes in above answer to get byte array imageview

    ImageView iv = (ImageView) findViewById(R.id.splashImageView);

    iv.setDrawingCacheEnabled(true);
            Bitmap bitmap = iv.getDrawingCache();
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            byte[] bitmapdata = stream.toByteArray();
    

提交回复
热议问题