Android sqlite数据库存取图片信息
存储图片:bitmap 

 

private byte[] getIconData(Bitmap bitmap){
    int size = bitmap.getWidth()*bitmap.getHeight()*4;
    ByteArrayOutputStream out = new ByteArrayOutputStream(size);
    try {
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
        out.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return out.toByteArray();
}

 

获取图片:

 

Bitmap getIconFromCursor(Cursor c, int iconIndex) {
    byte[] data = c.getBlob(iconIndex);
    try {
        return BitmapFactory.decodeByteArray(data, 0, data.length);
    } catch (Exception e) {
        return null;
    }
}


网盘android学习视频分享: http://pan.baidu.com/share/home?uk=1882162285

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
  • 2021-10-15
  • 2022-02-11
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-11-19
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
相关资源
相似解决方案