Android CursorWindow - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android CursorWindow class.

This code example shows how to use the following methods:allocRow, getNumRows, putBlob, putLong, setStartPosition
        return bRet;
    } 
 
    @Override 
    public void fillWindow (int pos, CursorWindow window) {
        int    nNumRows = window.getNumRows();
        int nCIndex = 0;
        window.setStartPosition(0);
 
        if (pos > -1) {
            if (nNumRows == 0) {
                window.allocRow();
                nNumRows = window.getNumRows();
            } 
 
            if (nNumRows == 1) {
                nCIndex = getColumnIndex(LENGTH);
                if (nCIndex > -1) {
                    window.putLong(lFileSize, 0, nCIndex);
                } 

7
CodeRank
This code example shows how to use the following methods:allocRow, getNumRows, putBlob, putLong, setStartPosition
        return bRet;
    } 
 
    @Override 
    public void fillWindow (int pos, CursorWindow window) {
        int    nNumRows = window.getNumRows();
        int nCIndex = 0;
        window.setStartPosition(0);
 
        if (pos > -1) {
            if (nNumRows == 0) {
                window.allocRow();
                nNumRows = window.getNumRows();
            } 
 
            if (nNumRows == 1) {
                nCIndex = getColumnIndex(LENGTH);
                if (nCIndex > -1) {
                    window.putLong(lFileSize, 0, nCIndex);
                } 

7
CodeRank
This code example shows how to use the following methods:allocRow, clear, putBlob, putLong, setNumColumns
  @Override public boolean isNull(int column) { throw new IllegalArgumentException("not implemented"); }
 
  @Override 
  public void fillWindow(int position, CursorWindow window) 
  { 
    window.acquireReference();
    window.clear();
    window.setStartPosition(0);
    window.setNumColumns(2);
    window.allocRow();
    window.putLong(0, 0, 0);
    window.putBlob(siddata, 0, 1);
    window.releaseReference();
  } 
} 
6
CodeRank
This code example shows how to use the following methods:freeLastRow, putBlob, putDouble, putNull
     */ 
    private boolean fillRow(CursorWindow window, Object value, int pos, int column) {
        if (putValue(window, value, pos, column)) {
            return true; 
        } else { 
            window.freeLastRow();
            return false; 
        } 
    } 
 
    /** 
     * 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) {

6
CodeRank
This code example shows how to use the following methods:allocRow, getDouble, getLong, getString, putString
    @SmallTest 
    public void testEmptyString() { 
        CursorWindow window = getOneByOneWindow();
 
        // put size 0 string and read it back as various types 
        assertTrue(window.putString("", 0, 0));
        assertEquals("", window.getString(0, 0));
        assertEquals(0, window.getLong(0, 0));
        assertEquals(0.0, window.getDouble(0, 0));
    } 
 
    private CursorWindow getOneByOneWindow() {
        CursorWindow window = new CursorWindow(false);
        assertTrue(window.setNumColumns(1));
        assertTrue(window.allocRow());
        return window;
    } 
     
    private static ArrayList<ArrayList> createTestList(int rows, int cols) {
        ArrayList<ArrayList> list = Lists.newArrayList();
6
CodeRank
This code example shows how to use the following methods:freeLastRow, putBlob, putDouble, putNull
     */ 
    private boolean fillRow(CursorWindow window, Object value, int pos, int column) {
        if (putValue(window, value, pos, column)) {
            return true; 
        } else { 
            window.freeLastRow();
            return false; 
        } 
    } 
 
    /** 
     * 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) {

6
CodeRank
This code example shows how to use the following methods:freeLastRow, putBlob, putDouble, putNull
     */ 
    private boolean fillRow(CursorWindow window, Object value, int pos, int column) {
        if (putValue(window, value, pos, column)) {
            return true; 
        } else { 
            window.freeLastRow();
            return false; 
        } 
    } 
 
    /** 
     * 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) {

5
CodeRank
This code example shows how to use the following methods:
public class MemoryCursor extends AbstractWindowedCursor {
 
    private final String[] mColumnNames;
 
    public MemoryCursor(String name, String[] columnNames) {
        setWindow(new CursorWindow(name));
        mColumnNames = columnNames;
    } 
 
    public void fillFromCursor(Cursor cursor) {
        DatabaseUtils.cursorFillWindow(cursor, 0, getWindow());
    } 
 
    @Override 
    public int getCount() { 
        return getWindow().getNumRows();
    } 
 
    @Override 
    public String[] getColumnNames() {
5
CodeRank
This code example shows how to use the following methods:getBlob
        // Deprecated, does nothing 
    } 
 
    @Override 
    public byte[] getBlob(int columnIndex) {
        return window.getBlob(curRow, columnIndex);
    } 
 
    @Override 
    public int getColumnCount() { 
        return numColumns;
    } 
 
    @Override 
    public int getColumnIndex(String columnName) {
        int ret = -1;
        Integer col = colNames.get(columnName);
        if (col != null) {
            ret = col;
        } 
3
CodeRank
This code example shows how to use the following methods:getInt
        return window.getShort(position, columnIndex);
    } 
 
    @Override 
    public int getInt(int columnIndex) {
        return window.getInt(position, columnIndex);
    } 
 
    @Override 
    public long getLong(int columnIndex) {
        return window.getLong(position, columnIndex);
    } 
 
    @Override 
    public float getFloat(int columnIndex) {
        return window.getFloat(position, columnIndex);
    } 
 
    @Override 
    public double getDouble(int columnIndex) {
3
CodeRank

Related Android CursorWindow Questions & Answers:

See Code Examples for Android CursorWindow Methods: