高分求助,各位大神帮帮忙啊!小女现在遇到了simplecursorAdapter 图片存取的问题,该怎么读出来放到Sqlite的问题了,多谢了
/**
* 将图片转化为二进制存储
* @param bitmap
*/
private void saveIcon(Bitmap bitmap) {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, os);
ZDBContext db=new ZDBContext(this);
SQLiteDatabase date=db.getWritableDatabase();
ContentValues cv=new ContentValues();
date.beginTransaction();
cv.put("photo",os.toByteArray());
date.insert("user", null, cv);
date.endTransaction();
Log.i(TAG,"saveIcon 000 OK");
private SQLiteDatabase read;
private Cursor c;
private ZDBContext db;
private ImageView imPhoto;
private Bitmap bitmap;
private SimpleCursorAdapter adapter;
Photo=(ImageView)findViewById(R.id.im_mem_photo);
db=new ZDBContext(this);
read=db.getReadableDatabase();
c=read.query("user",null,null,null,null,null,null);
try{
adapter=new SimpleCursorAdapter(this, R.layout.zmember_adapter, c,
new String[]{"roles","state","device","limits","photo"},
new int[]{R.id.bt_mem_role,R.id.im_mem_state,R.id.bt_mem_device,R.id.im_mem_limits,R.id.im_mem_photo});
setListAdapter(adapter);
reflashListView();
while(c.moveToNext()){
//从photo字段获得二进制数据图片,转化成图片
byte[] in=c.getBlob(c.getColumnIndex("photo"));
bitmap=BitmapFactory.decodeByteArray(in,0,in.length);
}
//展现在Listview上
imPhoto.setImageBitmap(bitmap);
c.close();
}catch(Exception e){
e.printStackTrace();
}
似乎simpleCursorAdapter无法处理图片,且导致用户信息与头像不匹配,个人认为是要重写apapter,但是我不会啊,希望各位大神帮帮忙,给个demo吧