本文整理匯總了Java中android.database.CursorWindow.putString方法的典型用法代碼示例。如果您正苦於以下問題:Java CursorWindow.putString方法的具體用法?Java CursorWindow.putString怎麽用?Java CursorWindow.putString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.CursorWindow
的用法示例。
在下文中一共展示了CursorWindow.putString方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: putValue
import android.database.CursorWindow; //導入方法依賴的package包/類
/**
* 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);
}
}
示例2: fillWindow
import android.database.CursorWindow; //導入方法依賴的package包/類
@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();
}
}
示例3: fillWindow
import android.database.CursorWindow; //導入方法依賴的package包/類
public void fillWindow(int position, CursorWindow window) {
int count = getCount();
if (position < 0 || position > count + 1) {
return;
}
window.acquireReference();
try {
int oldpos = getPosition();
int pos = position;
window.clear();
window.setStartPosition(position);
int columnNum = getColumnCount();
window.setNumColumns(columnNum);
while (moveToPosition(pos) && window.allocRow()) {
for (int i = 0; i < columnNum; i++) {
String field = getString(i);
if (field != null) {
if (!window.putString(field, pos, i)) {
window.freeLastRow();
break;
}
} else {
if (!window.putNull(pos, i)) {
window.freeLastRow();
break;
}
}
}
++pos;
}
moveToPosition(oldpos);
} catch (IllegalStateException e){
// simply ignore it
} finally {
window.releaseReference();
}
}
示例4: fillWindow
import android.database.CursorWindow; //導入方法依賴的package包/類
@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();
}
}
示例5: putToWindowPreHoneycomb
import android.database.CursorWindow; //導入方法依賴的package包/類
/**
* This solution is consistent with how Gingerbread implemented
* {@link android.database.AbstractCursor#fillWindow(int, android.database.CursorWindow)}.
*/
private static boolean putToWindowPreHoneycomb(Cursor cursor, int i,
CursorWindow window, int position) {
String value = cursor.getString(i);
final boolean success;
if (value != null) {
success = window.putString(value, position, i);
} else {
success = window.putNull(position, i);
}
return success;
}
示例6: cursorFillWindow
import android.database.CursorWindow; //導入方法依賴的package包/類
/**
* Fills the specified cursor window by iterating over the contents of the cursor.
* The window is filled until the cursor is exhausted or the window runs out
* of space.
*
* The original position of the cursor is left unchanged by this operation.
*
* @param cursor
* The cursor that contains the data to put in the window.
* @param position
* The start position for filling the window.
* @param window
* The window to fill.
*/
@TargetApi(11)
private static void cursorFillWindow(final Cursor cursor, int position,
final CursorWindow window) {
if (position < 0 || position >= cursor.getCount()) {
return;
}
final int oldPos = cursor.getPosition();
final int numColumns = cursor.getColumnCount();
window.clear();
window.setStartPosition(position);
window.setNumColumns(numColumns);
if (cursor.moveToPosition(position)) {
do {
if (!window.allocRow()) {
break;
}
for (int i = 0; i < numColumns; i++) {
// Cursor.getType() is only available from API 11 on, throw at least a
// meaningful error message.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
throw new UnsupportedOperationException(
"This method is only availble on devices running Honeycomb (API 11) or higher");
}
final int type = cursor.getType(i);
final boolean success;
switch (type) {
case Cursor.FIELD_TYPE_NULL:
success = window.putNull(position, i);
break;
case Cursor.FIELD_TYPE_INTEGER:
success = window.putLong(cursor.getLong(i), position, i);
break;
case Cursor.FIELD_TYPE_FLOAT:
success = window.putDouble(cursor.getDouble(i), position, i);
break;
case Cursor.FIELD_TYPE_BLOB:
byte[] blob = cursor.getBlob(i);
success = blob != null ? window.putBlob(blob, position, i) : window
.putNull(position, i);
break;
default: // assume value is convertible to String
case Cursor.FIELD_TYPE_STRING:
String string = cursor.getString(i);
success = string != null ? window.putString(string, position, i) : window
.putNull(position, i);
break;
}
if (!success) {
window.freeLastRow();
break;
}
}
position++;
} while (cursor.moveToNext());
}
cursor.moveToPosition(oldPos);
}
示例7: fillWindow
import android.database.CursorWindow; //導入方法依賴的package包/類
@Override
public void fillWindow(int aRowPosition, CursorWindow aDataWindow) {
if (aRowPosition<0 || aRowPosition>=getCount()) {
return;
}
aDataWindow.acquireReference();
try {
int oldRowPos = mPos;
mPos = aRowPosition - 1;
aDataWindow.clear();
aDataWindow.setStartPosition(aRowPosition);
int theNumCols = getColumnCount();
aDataWindow.setNumColumns(theNumCols);
while (moveToNext() && aDataWindow.allocRow()) {
for (int theColIdx=0; theColIdx<theNumCols; theColIdx++) {
boolean bPutNull = false;
boolean bPutFail = false;
switch (getColumnType(theColIdx)) {
case COLUMN_TYPE_STRING:
case COLUMN_TYPE_INTEGER:
String strField = getString(theColIdx);
if (strField != null)
bPutFail = (!aDataWindow.putString(strField,mPos,theColIdx));
else
bPutNull = true;
break;
case COLUMN_TYPE_LONG:
Long longField = getLong(theColIdx);
if (longField != null)
bPutFail = (!aDataWindow.putLong(longField,mPos,theColIdx));
else
bPutNull = true;
break;
case COLUMN_TYPE_FLOAT:
Double floatField = getDouble(theColIdx);
if (floatField != null)
bPutFail = (!aDataWindow.putDouble(floatField,mPos,theColIdx));
else
bPutNull = true;
break;
case COLUMN_TYPE_BLOB:
byte[] blobField = getBlob(theColIdx);
if (blobField != null)
bPutFail = (!aDataWindow.putBlob(blobField,mPos,theColIdx));
else
bPutNull = true;
break;
default:
bPutNull = true;
}
if (bPutNull) {
bPutFail = (!aDataWindow.putNull(mPos,theColIdx));
}
if (bPutFail) {
aDataWindow.freeLastRow();
break;
}
}
}
mPos = oldRowPos;
} catch (IllegalStateException e) {
// simply ignore it
} finally {
aDataWindow.releaseReference();
}
}