dimanche 13 décembre 2015

When I store a bytearray with more than 100,000 index into the sqlite, I can only get 20 index of it while I select it from the table

Here's what happen: When I convert a bitmap into a bytearray, the bytearray stores more than 100,000 index, but when I use the SELECT function to get the bytearray, the bytearray have only 20 index left. What happen?

My field is using BLOB to store the bytearray, and the following code is what I'm trying to get the bytearray:

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);
    }
}

And the query to get the bytearray:

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;
}

Please help.

Aucun commentaire:

Enregistrer un commentaire