Sqlite 我可以从字节数组中提取数据吗?

Sqlite 我可以从字节数组中提取数据吗?,sqlite,blob,Sqlite,Blob,这就是我如何成功获取应用程序的本机图标,并首先显示它,最后将其作为Blob发送到数据库中的方法: Builder builder = new AlertDialog.Builder(this); builder.setTitle("application_name"); builder.setMessage("Vous avez cliqué sur : " + resolveInfo.activityInfo.name);

这就是我如何成功获取应用程序的本机图标,并首先显示它,最后将其作为Blob发送到数据库中的方法:

Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("application_name");
            builder.setMessage("Vous avez cliqué sur : " + resolveInfo.activityInfo.name);
            Drawable iconApp;
            iconApp=resolveInfo.activityInfo.loadIcon(getPackageManager());

            BitmapDrawable bmd = (BitmapDrawable) iconApp;
            Bitmap bm = bmd.getBitmap();
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bm.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            byte[] bitmapdata = stream.toByteArray();
            SQLiteAdapter mySQLiteAdapter =new SQLiteAdapter(this.getApplicationContext());
            mySQLiteAdapter.openToWrite();
            String s=resolveInfo.activityInfo.name;
            mySQLiteAdapter.insertphoto(bitmapdata);
            mySQLiteAdapter.insert(s);
**我正在努力找回它: **就像这样:

SQLiteAdapter mySQLiteAdapter =new SQLiteAdapter(getApplicationContext());
                     mySQLiteAdapter.openToRead();
                     byte[] buffer = mySQLiteAdapter.queueAllphoto();
                     mySQLiteAdapter.close();

                     Drawable image = null;
                     image =  new BitmapDrawable(BitmapFactory.decodeByteArray(buffer, 0, buffer.length));
                     Bitmap b= convertByteArrayToBitmap(buffer);

                     //Bitmap bmp = BitmapFactory.decodeByteArray(content,0,content.length);

                     //image =  new BitmapDrawable(BitmapFactory.decodeByteArray(content, 0, content.length));
                     Builder builder = new AlertDialog.Builder(getBaseContext());
                     builder.setTitle("blob");
                     builder.setIcon(image);
                     builder.show();
最后这里是我的mmethode queuAllphoto类SQliteAdapter的一部分:

public byte[] queueAllphoto(){
        String[] columns = new String[]{KEY_CONTENT_photo};
        Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE_photo, columns, 
                null, null, null, null, null);
        byte[] result = null; 

        int index_CONTENT = cursor.getColumnIndex(KEY_CONTENT_photo);
        for(cursor.moveToFirst(); !(cursor.isAfterLast()); cursor.moveToNext()){
            result = cursor.getBlob(index_CONTENT) ;
        }

        return result;
    }

该方法返回一个字节数组,这就是我想处理的字节数组,例如,在AlerDialogue中显示每个blob!我正在努力将这个字节数组转换成一个可绘制的格式,因为我想通过改变返回类型(位图而不是字节数组)并添加Bitmap=BitmapFactory.decodeByteArray(result,0,result.length)在一个带有methode SetIcon(可绘制)的生成器(AlertDialogue)中使用它。我现在可以使用位图了 改变PAR可以得到这样的形象:

 Bitmap bm = null;
                 SQLiteAdapter mySQLiteAdapter =new SQLiteAdapter(getApplicationContext());
                 mySQLiteAdapter.openToRead();
                 bm=mySQLiteAdapter.queueAllphoto();
                 mySQLiteAdapter.close();
                 imageview.setImageBitmap(bm);
这就是queueAllphoto()方法:

公共位图queueAllphoto(){


我的问题太基本了吗?
     Bitmap bitmap;

    String[] columns = new String[]{KEY_CONTENT_photo};
    Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE_photo, columns, 
            null, null, null, null, null);
    byte[] result = null; 

    int index_CONTENT = cursor.getColumnIndex(KEY_CONTENT_photo);
    for(cursor.moveToFirst(); !(cursor.isAfterLast()); cursor.moveToNext()){
        result = cursor.getBlob(index_CONTENT) ;


    }

    bitmap=BitmapFactory.decodeByteArray(result, 0, result.length);
    return bitmap;
}