android图片保存到SQLlite如何实现?

//写入数据库  
     
        ImageView pic = (ImageView) findViewById(R.id.picture);
                                        Bitmap picdraw =pic.getDrawingCache(true)
picdraw.compress(Bitmap.CompressFormat.PNG, 100, os);
values.put("pic", os.toByteArray());

                                        //从数据库读取

                                        BitmapFactory.Options opts = new BitmapFactory.Options();  
opts.inJustDecodeBounds = true;  
BitmapFactory.decodeByteArray(c.getBlob(c.getColumnIndex("pic")), 0, c.getBlob(c.getColumnIndex("pic")).length,opts); 
opts.inSampleSize = Common.computeSampleSize(opts, -1, 130*100);  
opts.inJustDecodeBounds = false;
bmp = BitmapFactory.decodeByteArray(c.getBlob(c.getColumnIndex("pic")), 0, c.getBlob(c.getColumnIndex("pic")).length,opts);

                                        

posted @ 2016-01-07 16:09  抹茶MM  阅读(480)  评论(0编辑  收藏  举报