當前位置: 首頁>>代碼示例>>Java>>正文


Java CursorWindow.isLong方法代碼示例

本文整理匯總了Java中android.database.CursorWindow.isLong方法的典型用法代碼示例。如果您正苦於以下問題:Java CursorWindow.isLong方法的具體用法?Java CursorWindow.isLong怎麽用?Java CursorWindow.isLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.CursorWindow的用法示例。


在下文中一共展示了CursorWindow.isLong方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bindPreHoneycomb

import android.database.CursorWindow; //導入方法依賴的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));
    }
}
 
開發者ID:smukov,項目名稱:AvI,代碼行數:22,代碼來源:SQLiteAndroidDatabase.java

示例2: getCursorType

import android.database.CursorWindow; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
static int getCursorType(Cursor cursor, int i) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        return cursor.getType(i);
    }
    if (cursor instanceof AbstractWindowedCursor) {
        CursorWindow cursorWindow = ((AbstractWindowedCursor) cursor).getWindow();
        int pos = cursor.getPosition();
        int type = -1;
        if (cursorWindow.isNull(pos, i)) {
            type = FIELD_TYPE_NULL;
        } else if (cursorWindow.isLong(pos, i)) {
            type = FIELD_TYPE_INTEGER;
        } else if (cursorWindow.isFloat(pos, i)) {
            type = FIELD_TYPE_FLOAT;
        } else if (cursorWindow.isString(pos, i)) {
            type = FIELD_TYPE_STRING;
        } else if (cursorWindow.isBlob(pos, i)) {
            type = FIELD_TYPE_BLOB;
        }

        return type;
    }
    throw new RuntimeException("Unsupported cursor on this platform!");
}
 
開發者ID:microg,項目名稱:android_external_GmsApi,代碼行數:27,代碼來源:DataHolder.java

示例3: fillGingerbread

import android.database.CursorWindow; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private final void fillGingerbread(ExtendedJSONObject o, Cursor c, String f, int i) {
  if (!(c instanceof AbstractWindowedCursor)) {
    throw new IllegalStateException("Unable to handle cursors that don't have a CursorWindow!");
  }

  final AbstractWindowedCursor sqc = (AbstractWindowedCursor) c;
  final CursorWindow w = sqc.getWindow();
  final int pos = c.getPosition();
  if (w.isNull(pos, i)) {
    putNull(o, f);
  } else if (w.isString(pos, i)) {
    put(o, f, c.getString(i));
  } else if (w.isLong(pos, i)) {
    put(o, f, c.getLong(i));
  } else if (w.isFloat(pos, i)) {
    o.put(f, c.getDouble(i));
  } else if (w.isBlob(pos, i)) {
    // TODO: this probably doesn't serialize correctly.
    o.put(f, c.getBlob(i));
  }
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:23,代碼來源:ReadingListClientRecordFactory.java

示例4: getColumnType

import android.database.CursorWindow; //導入方法依賴的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);
    }
}
 
開發者ID:infinum,項目名稱:android_dbinspector,代碼行數:28,代碼來源:DatabaseHelper.java

示例5: getType

import android.database.CursorWindow; //導入方法依賴的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;
}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:32,代碼來源:TypeUtil.java


注:本文中的android.database.CursorWindow.isLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。