从SQLite中检索图像

时间:2017-12-15 22:13:19

标签: java android sqlite

您好我想从我的sqlite数据库获取图像,但我不能。这里是mycodes:

public Bitmap ResmiAl(int dersID){
        SQLiteDatabase db = this.getWritableDatabase();
        Cursor c = db.rawQuery("select * from fotolar_table",null);
        if(c.moveToNext()){
            byte [] image = c.getBlob(c.getColumnIndex("foto"));
            ByteArrayInputStream inputStream = new ByteArrayInputStream(image);
            Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
            //Bitmap foto = BitmapFactory.decodeByteArray(image,2,image.length);
            return bitmap;
        }
        else {
            return null;
        }
    }

0 个答案:

没有答案