Java Code Examples for android.database.CursorWindow#putNull()

The following examples show how to use android.database.CursorWindow#putNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SQLiteCursor.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Put the value in given window. If the value type is other than Long,
 * String, byte[] or Double, the NULL will be filled.
 *
 * @return true if succeeded.
 */
private boolean putValue(CursorWindow window, Object value, int pos, int column) {
    if (value == null) {
        return window.putNull(pos, column);
    } else if (value instanceof Long) {
        return window.putLong((Long) value, pos, column);
    } else if (value instanceof String) {
        return window.putString((String) value, pos, column);
    } else if (value instanceof byte[] && ((byte[]) value).length > 0) {
        return window.putBlob((byte[]) value, pos, column);
    } else if (value instanceof Double) {
        return window.putDouble((Double) value, pos, column);
    } else {
        return window.putNull(pos, column);
    }
}
 
Example 2
Source File: SQLiteCursor.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Put the value in given window. If the value type is other than Long,
 * String, byte[] or Double, the NULL will be filled.
 *
 * @return true if succeeded.
 */
private boolean putValue(CursorWindow window, Object value, int pos, int column) {
    if (value == null) {
        return window.putNull(pos, column);
    } else if (value instanceof Long) {
        return window.putLong((Long) value, pos, column);
    } else if (value instanceof String) {
        return window.putString((String) value, pos, column);
    } else if (value instanceof byte[] && ((byte[]) value).length > 0) {
        return window.putBlob((byte[]) value, pos, column);
    } else if (value instanceof Double) {
        return window.putDouble((Double) value, pos, column);
    } else {
        return window.putNull(pos, column);
    }
}
 
Example 3
Source File: SQLiteCursor.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Put the value in given window. If the value type is other than Long,
 * String, byte[] or Double, the NULL will be filled.
 *
 * @return true if succeeded.
 */
private boolean putValue(CursorWindow window, Object value, int pos, int column) {
    if (value == null) {
        return window.putNull(pos, column);
    } else if (value instanceof Long) {
        return window.putLong((Long) value, pos, column);
    } else if (value instanceof String) {
        return window.putString((String) value, pos, column);
    } else if (value instanceof byte[] && ((byte[]) value).length > 0) {
        return window.putBlob((byte[]) value, pos, column);
    } else if (value instanceof Double) {
        return window.putDouble((Double) value, pos, column);
    } else {
        return window.putNull(pos, column);
    }
}
 
Example 4
Source File: SQLiteCursor.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Put the value in given window. If the value type is other than Long,
 * String, byte[] or Double, the NULL will be filled.
 *
 * @return true if succeeded.
 */
private boolean putValue(CursorWindow window, Object value, int pos, int column) {
    if (value == null) {
        return window.putNull(pos, column);
    } else if (value instanceof Long) {
        return window.putLong((Long) value, pos, column);
    } else if (value instanceof String) {
        return window.putString((String) value, pos, column);
    } else if (value instanceof byte[] && ((byte[]) value).length > 0) {
        return window.putBlob((byte[]) value, pos, column);
    } else if (value instanceof Double) {
        return window.putDouble((Double) value, pos, column);
    } else {
        return window.putNull(pos, column);
    }
}
 
Example 5
Source File: SQLiteCursor.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Put the value in given window. If the value type is other than Long,
 * String, byte[] or Double, the NULL will be filled.
 *
 * @return true if succeeded.
 */
private boolean putValue(CursorWindow window, Object value, int pos, int column) {
    if (value == null) {
        return window.putNull(pos, column);
    } else if (value instanceof Long) {
        return window.putLong((Long) value, pos, column);
    } else if (value instanceof String) {
        return window.putString((String) value, pos, column);
    } else if (value instanceof byte[] && ((byte[]) value).length > 0) {
        return window.putBlob((byte[]) value, pos, column);
    } else if (value instanceof Double) {
        return window.putDouble((Double) value, pos, column);
    } else {
        return window.putNull(pos, column);
    }
}
 
Example 6
Source File: ImpsProvider.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fillWindow(int position, CursorWindow window) {
    if (position < 0 || position > getCount()) {
        return;
    }
    window.acquireReference();
    try {
        moveToPosition(position - 1);
        window.clear();
        window.setStartPosition(position);
        int columnNum = getColumnCount();
        window.setNumColumns(columnNum);
        boolean isFull = false;
        int numRows = 10;

        while (!isFull && --numRows > 0 && moveToNext() && window.allocRow()) {
            for (int i = 0; i < columnNum; i++) {
                String field = getString(i);
                if (field != null) {
                    if (!window.putString(field, getPosition(), i)) {
                        window.freeLastRow();
                        isFull = true;
                        break;
                    }
                } else {
                    if (!window.putNull(getPosition(), i)) {
                        window.freeLastRow();
                        isFull = true;
                        break;
                    }
                }
            }
        }
    } catch (IllegalStateException e) {
        // simply ignore it
    } finally {
        window.releaseReference();
    }
}