geopackage-sdk/src/main/java/mil/nga/geopackage/user/UserInvalidCursor.java
private void readBlobValue(UserRow row, UserColumn column) {

        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        try {

            byte[] blobChunk = new byte[]{0};
            for (int i = 1; blobChunk.length > 0; i += CHUNK_SIZE) {
                if (i > 1) {
                    byteStream.write(blobChunk);
                }
                blobChunk = new byte[]{};
                String query = "select substr(" +
                        CoreSQLUtils.quoteWrap(column.getName()) + ", " + i + ", " + CHUNK_SIZE + ") from "
                        + CoreSQLUtils.quoteWrap(dao.getTableName()) + " where "
                        + CoreSQLUtils.quoteWrap(row.getPkColumn().getName()) + " = " + row.getId();
                Cursor blobCursor = dao.getDatabaseConnection().getDb().rawQuery(query, null);
                try {
                    if (blobCursor.moveToNext()) {
                        blobChunk = blobCursor.getBlob(0);
                    }
                } finally {
                    blobCursor.close();
                }
            }
            byte[] blob = byteStream.toByteArray();
            row.setValue(column.getIndex(), blob);

        } catch (IOException e) {
            Log.e(UserInvalidCursor.class.getSimpleName(), "Failed to read large blob value. Table: "
                    + dao.getTableName() + ", Column: " + column.getName() + ", Position: " + getPosition(), e);
        } finally {
            IOUtils.closeQuietly(byteStream);
        }
    }
private void readBlobValue(UserRow row, UserColumn column) {

        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        try {

            byte[] blobChunk = new byte[]{0};
            for (int i = 1; blobChunk.length > 0; i += CHUNK_SIZE) {
                if (i > 1) {
                    byteStream.write(blobChunk);
                }
                blobChunk = new byte[]{};
                String query = "select substr(" +
                        CoreSQLUtils.quoteWrap(column.getName()) + ", " + i + ", " + CHUNK_SIZE + ") from "
                        + CoreSQLUtils.quoteWrap(dao.getTableName()) + " where "
                        + CoreSQLUtils.quoteWrap(row.getPkColumn().getName()) + " = " + row.getId();
                Cursor blobCursor = dao.getDatabaseConnection().getDb().rawQuery(query, null);
                try {
                    if (blobCursor.moveToNext()) {
                        blobChunk = blobCursor.getBlob(0);
                    }
                } finally {
                    blobCursor.close();
                }
            }
            byte[] blob = byteStream.toByteArray();
            row.setValue(column.getIndex(), blob);

        } catch (IOException e) {
            Log.e(UserInvalidCursor.class.getSimpleName(), "Failed to read large blob value. Table: "
                    + dao.getTableName() + ", Column: " + column.getName() + ", Position: " + getPosition(), e);
        } finally {
            IOUtils.closeQuietly(byteStream);
        }
    }
private void readBlobValue ( UserRow row , UserColumn column ) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream ( ) ; try { byte [ ] blobChunk = new byte [ ] { 0 } ; for ( int i = 1 ; blobChunk . length > 0 ; i += CHUNK_SIZE ) { if ( i > 1 ) { byteStream . write ( blobChunk ) ; } blobChunk = new byte [ ] { } ; String query = "select substr(" + CoreSQLUtils . quoteWrap ( column . getName ( ) ) + ", " + i + ", " + CHUNK_SIZE + ") from " + CoreSQLUtils . quoteWrap ( dao . getTableName ( ) ) + " where " + CoreSQLUtils . quoteWrap ( row . getPkColumn ( ) . getName ( ) ) + " = " + row . getId ( ) ; Cursor blobCursor = dao . getDatabaseConnection ( ) . getDb ( ) . rawQuery ( query , null ) ; try { if ( blobCursor . moveToNext ( ) ) { blobChunk = blobCursor . getBlob ( 0 ) ; } } finally { blobCursor . close ( ) ; } } byte [ ] blob = byteStream . toByteArray ( ) ; row . setValue ( column . getIndex ( ) , blob ) ; } catch ( IOException e ) { Log . e ( UserInvalidCursor . class . getSimpleName ( ) , "Failed to read large blob value. Table: " + dao . getTableName ( ) + ", Column: " + column . getName ( ) + ", Position: " + getPosition ( ) , e ) ; } finally { IOUtils . closeQuietly ( byteStream ) ; } }
Read the blob column value in chunks

@param row    user row
@param column user blob column
Read the blob column value in chunks