下面列出了android.database.CursorWindow#putString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
@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();
}
}