当前位置:首页 > 数据库 > SQlite

我在sqlite中存储具有超过100,000个索引的字节数组时,只能从表中选择它的20个索引

这是发生了什么:
当我将位图转换为字节数组时,字节数组存储了超过100,000个索引,但是当我使用SELECT函数获取字节数组时,字节数组只剩下20个索引.发生什么事?

我的字段正在使用BLOB存储字节数组,以下代码是我试图获取字节数组的内容:

private void insertAttachmentRecord(int parentid) {

    for(int k = 0; k < attachmentarray.size(); k++) {
        byte[] claimAttachmentByteArray;
        newAttachmentRecord = new ContentValues();
        claimAttachmentByteArray = attachmentarray.get(k).getImageByteArray();
        newAttachmentRecord.put("claimattachmentimage", claimAttachmentByteArray);
        newAttachmentRecord.put("parent_id", parentid);
        claiminfoDB.insert(DBATTACHMENT_TABLE, null, newAttachmentRecord);
    }
}

并获取字节数组的查询:

private ArrayList<ClaimViewResult> GetClaimViewResult() {
    ArrayList<ClaimViewResult> results = new ArrayList<>();

    Cursor c2 = claiminfoDB.rawQuery("SELECT 'claimattachmentimage' FROM 'claimattachment' WHERE parent_id = "+bundletableId, null);

    if (c2.getCount() != 0) {
        c2.moveToFirst();

        ClaimViewResult cvr = new ClaimViewResult();
        byte[] imagebytearray = c2.getBlob(0);
        Bitmap bitmap = BitmapFactory.decodeByteArray(imagebytearray, 0, imagebytearray.length);
        cvr.setBitmap(bitmap);
        cvr.setFilename(getFilename());
        results.add(cvr);
        while (c2.moveToNext()) {
            cvr = new ClaimViewResult();
            imagebytearray = c2.getBlob(0);
            bitmap = BitmapFactory.decodeByteArray(imagebytearray, 0, imagebytearray.length);
            cvr.setBitmap(bitmap);
            cvr.setFilename(getFilename());

            results.add(cvr);
        }
    }
    return results;
}

请帮忙.

解决方法:

可能需要更改保存位图的方案吗?例如,您可以将位图存储在内部应用程序的目录中,并将此图像的路径保存在数据库中.

另外,您可以尝试更改您的选择查询,如下所示:

SELECT * FROM your_table;

我认为您只能接收20个字节,因为您选择单词而不是列(我的意思是查询中的“ claimattachmentimage”)


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!