dumpCurrentRowToStringBuffer method

Future<void> dumpCurrentRowToStringBuffer(
  1. Cursor cursor,
  2. StringBuffer buffer
)

Prints the contents of a Cursor's current row to a string buffer.

See: https://developer.android.com/reference/android/database/DatabaseUtils#dumpCurrentRowToString(android.database.Cursor)

Implementation

static Future<void> dumpCurrentRowToStringBuffer(
    final Cursor cursor, final StringBuffer buffer) async {
  assert(Platform.isAndroid);

  buffer.write("[");
  for (var columnIndex = 0;
      columnIndex < cursor.getColumnCount();
      columnIndex++) {
    if (columnIndex > 0) buffer.write(", ");
    switch (cursor.getType(columnIndex)) {
      case Cursor.FIELD_TYPE_NULL:
        buffer.write("null");
        break;
      case Cursor.FIELD_TYPE_INTEGER:
        buffer.write(cursor.getLong(columnIndex));
        break;
      case Cursor.FIELD_TYPE_FLOAT:
        buffer.write(cursor.getDouble(columnIndex));
        break;
      case Cursor.FIELD_TYPE_STRING:
        buffer.write(cursor.getString(columnIndex));
        break;
      case Cursor.FIELD_TYPE_BLOB:
        buffer.write(cursor.getBlob(columnIndex));
        break;
      default:
        assert(false); // unreachable
        throw AssertionError();
    }
  }
  buffer.write("]");
}