本文整理匯總了Java中android.database.sqlite.SQLiteCursor.getWindow方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteCursor.getWindow方法的具體用法?Java SQLiteCursor.getWindow怎麽用?Java SQLiteCursor.getWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.sqlite.SQLiteCursor
的用法示例。
在下文中一共展示了SQLiteCursor.getWindow方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: bindPreHoneycomb
import android.database.sqlite.SQLiteCursor; //導入方法依賴的package包/類
private void bindPreHoneycomb(JSONObject row, String key, Cursor cursor, int i) throws JSONException {
// Since cursor.getType() is not available pre-honeycomb, this is
// a workaround so we don't have to bind everything as a string
// Details here: http://stackoverflow.com/q/11658239
SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
CursorWindow cursorWindow = sqLiteCursor.getWindow();
int pos = cursor.getPosition();
if (cursorWindow.isNull(pos, i)) {
row.put(key, JSONObject.NULL);
} else if (cursorWindow.isLong(pos, i)) {
row.put(key, cursor.getLong(i));
} else if (cursorWindow.isFloat(pos, i)) {
row.put(key, cursor.getDouble(i));
/* ** Read BLOB as Base-64 DISABLED in this branch:
} else if (cursorWindow.isBlob(pos, i)) {
row.put(key, new String(Base64.encode(cursor.getBlob(i), Base64.DEFAULT)));
// ** Read BLOB as Base-64 DISABLED to HERE. */
} else { // string
row.put(key, cursor.getString(i));
}
}
示例2: getColumnType
import android.database.sqlite.SQLiteCursor; //導入方法依賴的package包/類
/**
* Compat method so we can get type of column on API < 11.
* Source: http://stackoverflow.com/a/20685546/2643666
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static int getColumnType(Cursor cursor, int col) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
CursorWindow cursorWindow = sqLiteCursor.getWindow();
int pos = cursor.getPosition();
int type = -1;
if (cursorWindow.isNull(pos, col)) {
type = FIELD_TYPE_NULL;
} else if (cursorWindow.isLong(pos, col)) {
type = FIELD_TYPE_INTEGER;
} else if (cursorWindow.isFloat(pos, col)) {
type = FIELD_TYPE_FLOAT;
} else if (cursorWindow.isString(pos, col)) {
type = FIELD_TYPE_STRING;
} else if (cursorWindow.isBlob(pos, col)) {
type = FIELD_TYPE_BLOB;
}
return type;
} else {
return cursor.getType(col);
}
}
示例3: getType
import android.database.sqlite.SQLiteCursor; //導入方法依賴的package包/類
private static int getType(Cursor cursor, int columnIndex) throws Exception
{
if (Build.VERSION.SDK_INT >= 11)
{
return cursor.getType(columnIndex);
}
SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
CursorWindow cursorWindow = sqLiteCursor.getWindow();
int pos = cursor.getPosition();
int type = -1;
if (cursorWindow.isNull(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_NULL;
} else if (cursorWindow.isLong(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_INTEGER;
} else if (cursorWindow.isFloat(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_FLOAT;
} else if (cursorWindow.isString(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_STRING;
} else if (cursorWindow.isBlob(pos, columnIndex))
{
type = Cursor.FIELD_TYPE_BLOB;
}
return type;
}