Example usage for android.database CursorWindow putBlob

List of usage examples for android.database CursorWindow putBlob

Introduction

In this page you can find the example usage for android.database CursorWindow putBlob.

Prototype

public boolean putBlob(byte[] value, int row, int column) 

Source Link

Document

Copies a byte array into the field at the specified row and column index.

Usage

From source file:mobisocial.musubi.provider.IdentityCursorWrapper.java

@Override
public void fillWindow(int position, CursorWindow window) {
    if (position < 0 || position > getCount()) {
        return;/*from   w w  w .  j  a  v a2 s  .c  o m*/
    }
    window.acquireReference();

    try {
        moveToPosition(position - 1);
        window.clear();
        window.setStartPosition(position);
        int columnNum = getColumnCount();
        window.setNumColumns(columnNum);
        while (moveToNext() && window.allocRow()) {
            for (int i = 0; i < columnNum; i++) {
                if (i == colThumb || i == colHash) {
                    byte[] field = getBlob(i);
                    if (!window.putBlob(field, getPosition(), i)) {
                        window.freeLastRow();
                        break;
                    }
                } else {
                    String field = getString(i);
                    if (field != null) {
                        if (!window.putString(field, getPosition(), i)) {
                            window.freeLastRow();
                            break;
                        }
                    } else {
                        if (!window.putNull(getPosition(), i)) {
                            window.freeLastRow();
                            break;
                        }
                    }
                }
            }
        }
    } catch (IllegalStateException e) {
        // simply ignore it
    } finally {
        window.releaseReference();
    }
}