android.database.Cursor.getType()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(357)

本文整理了Java中android.database.Cursor.getType()方法的一些代码示例,展示了Cursor.getType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cursor.getType()方法的具体详情如下:
包路径:android.database.Cursor
类名称:Cursor
方法名:getType

Cursor.getType介绍

暂无

代码示例

代码示例来源:origin: k9mail/k-9

@Override
public int getType(int columnIndex) {
  return mActiveCursor.getType(columnIndex);
}

代码示例来源:origin: aa112901/remusic

@Override
public int getType(final int column) {
  return mQueueCursor.getType(column);
}

代码示例来源:origin: naman14/Timber

@Override
public int getType(final int column) {
  return mQueueCursor.getType(column);
}

代码示例来源:origin: robolectric/robolectric

@Override @Implementation
public int getType(int columnIndex) {
 return wrappedCursor.getType(columnIndex);
}

代码示例来源:origin: facebook/stetho

for (int row = 0; row < limit && cursor.moveToNext(); row++) {
 for (int column = 0; column < numColumns; column++) {
  switch (cursor.getType(column)) {
   case Cursor.FIELD_TYPE_NULL:
    flatList.add(null);

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetTypeWhenBlob() throws Exception {
 String sql = "UPDATE table_name set blob_value=? where id=1234";
 byte[] byteData = sql.getBytes(UTF_8);
 database.execSQL(sql, new Object[]{byteData});
 assertThat(cursor.moveToFirst()).isTrue();
 assertThat(cursor.getType(5)).isEqualTo(Cursor.FIELD_TYPE_BLOB);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetTypeWhenLong() throws Exception {
 assertThat(cursor.moveToFirst()).isTrue();
 assertThat(cursor.getType(2)).isEqualTo(Cursor.FIELD_TYPE_INTEGER);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetNullNumberValues() throws Exception {
 String sql = "UPDATE table_name set long_value=NULL, float_value=NULL, double_value=NULL";
 database.execSQL(sql);
 assertThat(cursor.moveToFirst()).isTrue();
 assertThat(cursor.getType(2)).isEqualTo(Cursor.FIELD_TYPE_NULL);
 assertThat(cursor.getLong(2)).isEqualTo(0);
 assertThat(cursor.getType(3)).isEqualTo(Cursor.FIELD_TYPE_NULL);
 assertThat(cursor.getFloat(3)).isEqualTo(0f);
 assertThat(cursor.getType(4)).isEqualTo(Cursor.FIELD_TYPE_NULL);
 assertThat(cursor.getDouble(4)).isEqualTo(0d);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetTypeWhenFloat() throws Exception {
 assertThat(cursor.moveToFirst()).isTrue();
 assertThat(cursor.getType(3)).isEqualTo(Cursor.FIELD_TYPE_FLOAT);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetTypeWhenDouble() throws Exception {
 assertThat(cursor.moveToFirst()).isTrue();
 assertThat(cursor.getType(4)).isEqualTo(Cursor.FIELD_TYPE_FLOAT);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetTypeWhenInteger() throws Exception {
 assertThat(cursor.moveToFirst()).isTrue();
 assertThat(cursor.getType(0)).isEqualTo(Cursor.FIELD_TYPE_INTEGER);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetTypeWhenString() throws Exception {
 assertThat(cursor.moveToFirst()).isTrue();
 assertThat(cursor.getType(1)).isEqualTo(Cursor.FIELD_TYPE_STRING);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetTypeWhenNull() throws Exception {
 assertThat(cursor.moveToFirst()).isTrue();
 assertThat(cursor.getType(5)).isEqualTo(Cursor.FIELD_TYPE_NULL);
}

代码示例来源:origin: amitshekhariitbhu/Android-Debug-Database

for (int i = 0; i < cursor.getColumnCount(); i++) {
  TableDataResponse.ColumnData columnData = new TableDataResponse.ColumnData();
  switch (cursor.getType(i)) {
    case Cursor.FIELD_TYPE_BLOB:
      columnData.dataType = DataType.TEXT;

代码示例来源:origin: andpor/react-native-sqlite-storage

@SuppressLint("NewApi")
private void bindRow(WritableMap row, String key, Cursor cur, int i) {
  int curType = cur.getType(i);
  switch (curType) {
    case Cursor.FIELD_TYPE_NULL:
      row.putNull(key);
      break;
    case Cursor.FIELD_TYPE_INTEGER:
      row.putDouble(key, cur.getLong(i));
      break;
    case Cursor.FIELD_TYPE_FLOAT:
      row.putDouble(key, cur.getDouble(i));
      break;
    case Cursor.FIELD_TYPE_BLOB:
      row.putString(key, new String(Base64.encode(cur.getBlob(i), Base64.DEFAULT)));
      break;
    case Cursor.FIELD_TYPE_STRING:
    default:
      row.putString(key, cur.getString(i));
      break;
  }
}

代码示例来源:origin: andpor/react-native-sqlite-storage

@SuppressLint("NewApi")
private void bindRow(WritableMap row, String key, Cursor cur, int i) {
  int curType = cur.getType(i);
  switch (curType) {
    case Cursor.FIELD_TYPE_NULL:
      row.putNull(key);
      break;
    case Cursor.FIELD_TYPE_INTEGER:
      row.putDouble(key, cur.getLong(i));
      break;
    case Cursor.FIELD_TYPE_FLOAT:
      row.putDouble(key, cur.getDouble(i));
      break;
    case Cursor.FIELD_TYPE_BLOB:
      row.putString(key, new String(Base64.encode(cur.getBlob(i), Base64.DEFAULT)));
      break;
    case Cursor.FIELD_TYPE_STRING:
    default: /* (not expected) */
      row.putString(key, cur.getString(i));
      break;
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldCorrectlyReturnNullValues() {
  database.execSQL("CREATE TABLE null_test (col_int INTEGER, col_text TEXT, col_real REAL, col_blob BLOB)");
  ContentValues data = new ContentValues();
  data.putNull("col_int");
  data.putNull("col_text");
  data.putNull("col_real");
  data.putNull("col_blob");
  assertThat(database.insert("null_test", null, data)).isAtLeast(0L);
  Cursor nullValuesCursor = database.query("null_test", null, null, null, null, null, null);
  nullValuesCursor.moveToFirst();
  final int colsCount = 4;
  for (int i = 0; i < colsCount; i++) {
    assertThat(nullValuesCursor.getType(i)).isEqualTo(Cursor.FIELD_TYPE_NULL);
    assertThat(nullValuesCursor.getString(i)).isNull();
  }
  assertThat(nullValuesCursor.getBlob(3)).isNull();
}

代码示例来源:origin: parse-community/Parse-SDK-Android

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public int getType(int columnIndex) {
  return cursor.getType(columnIndex);
}

代码示例来源:origin: ac-pm/Inspeckage

for (int i = 0; i < x; i++) {
  if (cursor.getType(i) == Cursor.FIELD_TYPE_BLOB) {
    String blob = Base64.encodeToString(cursor.getBlob(i), Base64.NO_WRAP);
    sb.append(cursor.getColumnName(i) + "=" + blob + ",");

代码示例来源:origin: willowtreeapps/Hyperion-Android

for (int col = 0; col < cursor.getColumnCount(); col++) {
  TextView textView = new TextView(context);
  if (cursor.getType(col) == FIELD_TYPE_BLOB) {

相关文章