Android SQLite存取图像的简单方法如下:

  //Bitmap to byte[]  public byte[] bmpToByteArray(Bitmap bmp){      //Default size is 32 bytes      ByteArrayOutputStream bos = new ByteArrayOutputStream();      try {    bmp.compress(Bitmap.CompressFormat.JPEG, 100, bos);    bos.close();  } catch (IOException e) {     e.printStackTrace();    } return bos.toByteArray();  }  //Cursor to bitmap  Bitmap cursorToBmp(Cursor c, int columnIndex) {        byte[] data = c.getBlob(columnIndex);        try {            return BitmapFactory.decodeByteArray(data, 0, data.length);        } catch (Exception e) {            return null;        } }

图像存储调用:
ContentValues values = new ContentValues();
values.put("img", bmpToByteArray(bmp);
图像读取调用:
Cursor c = db.rawQuery("select * from info", null);
c.moveToLast();
Bitmap bmp = cursorToBmp(c, c.getColumnIndex("img"));


更多相关文章

  1. Android中的Picasso实现圆角图片
  2. 高斯模糊效果移植到android系统
  3. Android中findViewById返回为空null的快速解决办法
  4. Android(安卓)SQLite数据库
  5. Android:Parcelable/Bundle/IBinder
  6. android旋转图像Matrix
  7. android Intent Flags详解
  8. android全屏设置
  9. android Intent Flags详解

随机推荐

  1. Android(安卓)SDK Installed On Mac
  2. android sdk配置
  3. 在android中使用SOAP与webservice进行数
  4. 在Android中查看和管理sqlite数据库
  5. Android俄罗斯方块游戏源码
  6. 将LMbench移植到Android上
  7. Android输入系统与Qwerty物理键盘的支持
  8. RadioButton 选择框的位置
  9. Android(安卓)之Service的使用及生命周期
  10. android Intent机制详解