Java Code Examples for android.database.Cursor#FIELD_TYPE_FLOAT

The following examples show how to use android.database.Cursor#FIELD_TYPE_FLOAT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuntimesThemeProviderTest.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
private boolean columnIsDouble(Cursor cursor, String column)
{
    if (cursor != null) {
        try {
            int index = cursor.getColumnIndex(column);
            if (cursor.getType(index) == Cursor.FIELD_TYPE_FLOAT)
            {
                double value = cursor.getDouble(index);
                return true;
            }

        } catch (NumberFormatException e) {
            return false;
        }
    }
    return false;
}
 
Example 2
Source File: OCursorUtils.java    From framework with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Object cursorValue(String column, Cursor cr) {
    Object value = false;
    int index = cr.getColumnIndex(column);
    switch (cr.getType(index)) {
        case Cursor.FIELD_TYPE_NULL:
            value = false;
            break;
        case Cursor.FIELD_TYPE_STRING:
            value = cr.getString(index);
            break;
        case Cursor.FIELD_TYPE_INTEGER:
            value = cr.getInt(index);
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            value = cr.getFloat(index);
            break;
        case Cursor.FIELD_TYPE_BLOB:
            value = cr.getBlob(index);
            break;
    }
    return value;
}
 
Example 3
Source File: PermissionTester.java    From PermissionAgent with Apache License 2.0 6 votes vote down vote up
public static void read(Cursor cursor) {
    int count = cursor.getCount();
    if (count > 0) {
        cursor.moveToFirst();
        int type = cursor.getType(0);
        switch (type) {
            case Cursor.FIELD_TYPE_BLOB:
            case Cursor.FIELD_TYPE_NULL: {
                break;
            }
            case Cursor.FIELD_TYPE_INTEGER:
            case Cursor.FIELD_TYPE_FLOAT:
            case Cursor.FIELD_TYPE_STRING:
            default: {
                cursor.getString(0);
                break;
            }
        }
    }
}
 
Example 4
Source File: PermissionTester.java    From PermissionAgent with Apache License 2.0 6 votes vote down vote up
public static void read(Cursor cursor) {
    int count = cursor.getCount();
    if (count > 0) {
        cursor.moveToFirst();
        int type = cursor.getType(0);
        switch (type) {
            case Cursor.FIELD_TYPE_BLOB:
            case Cursor.FIELD_TYPE_NULL: {
                break;
            }
            case Cursor.FIELD_TYPE_INTEGER:
            case Cursor.FIELD_TYPE_FLOAT:
            case Cursor.FIELD_TYPE_STRING:
            default: {
                cursor.getString(0);
                break;
            }
        }
    }
}
 
Example 5
Source File: DBProxy.java    From android-orm with Apache License 2.0 6 votes vote down vote up
/**
 * 封装内容到Map对象
 *
 * @param cursor
 * @param columnName
 * @param map
 */
private void putMapKeyValue(Cursor cursor, String columnName, Map<String, Object> map) {
    int columnIndex = cursor.getColumnIndex(columnName);
    int type = cursor.getType(columnIndex);
    switch (type) {
        case Cursor.FIELD_TYPE_INTEGER:
            map.put(columnName, cursor.getLong(columnIndex));
            break;
        case Cursor.FIELD_TYPE_STRING:
            map.put(columnName, cursor.getString(columnIndex));
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            map.put(columnName, cursor.getFloat(columnIndex));
            break;
        case Cursor.FIELD_TYPE_BLOB:
            map.put(columnName, cursor.getBlob(columnIndex));
            break;
        case Cursor.FIELD_TYPE_NULL:
            map.put(columnName, cursor.getString(columnIndex));
            break;
        default:
            break;
    }
}
 
Example 6
Source File: MapperAdapter.java    From wellsql with MIT License 6 votes vote down vote up
@Override
public T convert(Cursor item) {
    Map<String, Object> map = new HashMap<>();
    for (String column : item.getColumnNames()) {
        int columnIndex = item.getColumnIndex(column);
        switch (item.getType(columnIndex)) {
            case Cursor.FIELD_TYPE_INTEGER:
                map.put(column, item.getLong(columnIndex));
                break;
            case Cursor.FIELD_TYPE_STRING:
                map.put(column, item.getString(columnIndex));
                break;
            case Cursor.FIELD_TYPE_FLOAT:
                map.put(column, item.getFloat(columnIndex));
                break;
            case Cursor.FIELD_TYPE_BLOB:
                map.put(column, item.getBlob(columnIndex));
                break;
        }
    }
    return mMapper.convert(map);
}
 
Example 7
Source File: SQLiteAndroidDatabase.java    From AvI with MIT License 6 votes vote down vote up
@SuppressLint("NewApi")
private void bindPostHoneycomb(JSONObject row, String key, Cursor cur, int i) throws JSONException {
    int curType = cur.getType(i);

    switch (curType) {
        case Cursor.FIELD_TYPE_NULL:
            row.put(key, JSONObject.NULL);
            break;
        case Cursor.FIELD_TYPE_INTEGER:
            row.put(key, cur.getLong(i));
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            row.put(key, cur.getDouble(i));
            break;
        /* ** Read BLOB as Base-64 DISABLED in this branch:
        case Cursor.FIELD_TYPE_BLOB:
            row.put(key, new String(Base64.encode(cur.getBlob(i), Base64.DEFAULT)));
            break;
        // ** Read BLOB as Base-64 DISABLED to HERE. */
        case Cursor.FIELD_TYPE_STRING:
        default: /* (not expected) */
            row.put(key, cur.getString(i));
            break;
    }
}
 
Example 8
Source File: OCursorListAdapter.java    From hr with GNU Affero General Public License v3.0 6 votes vote down vote up
private Object getValue(Cursor c, String column) {
    Object value = false;
    int index = c.getColumnIndex(column);
    switch (c.getType(index)) {
        case Cursor.FIELD_TYPE_NULL:
            value = false;
            break;
        case Cursor.FIELD_TYPE_BLOB:
        case Cursor.FIELD_TYPE_STRING:
            value = c.getString(index);
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            value = c.getFloat(index);
            break;
        case Cursor.FIELD_TYPE_INTEGER:
            value = c.getInt(index);
            break;
    }
    return value;
}
 
Example 9
Source File: OCursorUtils.java    From hr with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Object cursorValue(String column, Cursor cr) {
    Object value = false;
    int index = cr.getColumnIndex(column);
    switch (cr.getType(index)) {
        case Cursor.FIELD_TYPE_NULL:
            value = false;
            break;
        case Cursor.FIELD_TYPE_STRING:
            value = cr.getString(index);
            break;
        case Cursor.FIELD_TYPE_INTEGER:
            value = cr.getInt(index);
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            value = cr.getFloat(index);
            break;
        case Cursor.FIELD_TYPE_BLOB:
            value = cr.getBlob(index);
            break;
    }
    return value;
}
 
Example 10
Source File: DbSqlite.java    From SqliteLookup with Apache License 2.0 5 votes vote down vote up
/**
 * set data in cursor to ResultSet List
 * @param cursor
 * @param resultList the data will set in it
 */
private void parseCursorToResult(Cursor cursor,List<ResultSet> resultList){
	int columnCount;
	int columnType;
	Object columnVal = null;
	while (cursor.moveToNext()) {
		columnCount = cursor.getColumnCount();
		ResultSet result = new ResultSet();
		for (int index = 0; index < columnCount; ++index) {
			columnType = cursor.getType(index);
			switch (columnType) {
			case Cursor.FIELD_TYPE_BLOB:
				columnVal = cursor.getBlob(index);
				break;
			case Cursor.FIELD_TYPE_FLOAT:
				columnVal = cursor.getDouble(index);
				break;
			case Cursor.FIELD_TYPE_INTEGER:
				columnVal = cursor.getLong(index);
				break;
			case Cursor.FIELD_TYPE_NULL:
				columnVal = null;
				break;
			default:
				columnVal = cursor.getString(index);
				break;
			}
			result.setValue(cursor.getColumnName(index), columnVal);
		}
		resultList.add(result);
	}
}
 
Example 11
Source File: DataBaseUtils.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
public static int getTypeOfObject(Object obj) {
    if (obj == null) {
        return Cursor.FIELD_TYPE_NULL;
    } else if (obj instanceof byte[]) {
        return Cursor.FIELD_TYPE_BLOB;
    } else if (obj instanceof Float || obj instanceof Double) {
        return Cursor.FIELD_TYPE_FLOAT;
    } else if (obj instanceof Long || obj instanceof Integer
            || obj instanceof Short || obj instanceof Byte) {
        return Cursor.FIELD_TYPE_INTEGER;
    } else {
        return Cursor.FIELD_TYPE_STRING;
    }
}
 
Example 12
Source File: Utils.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a cursor to a bundle. Field datatypes will be maintained. Floats will be stored in
 * the Bundle as Doubles, and Integers will be stored as Longs due to Cursor limitationcs
 *
 * @param cursor The cursor to convert to a Bundle. This must be positioned to the row to be
 *               read
 * @return The converted bundle
 */
public static Bundle cursorToBundle(Cursor cursor) {

    final int columnCount = cursor.getColumnCount();
    final Bundle bundle = new Bundle(columnCount);

    for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {

        final String columnName = cursor.getColumnName(columnIndex);
        switch (cursor.getType(columnIndex)) {

            case Cursor.FIELD_TYPE_STRING: {
                bundle.putString(columnName, cursor.getString(columnIndex));
                break;
            }

            case Cursor.FIELD_TYPE_BLOB: {
                bundle.putByteArray(columnName, cursor.getBlob(columnIndex));
                break;
            }

            case Cursor.FIELD_TYPE_FLOAT: {
                bundle.putDouble(columnName, cursor.getDouble(columnIndex));
                break;
            }

            case Cursor.FIELD_TYPE_INTEGER: {
                bundle.putLong(columnName, cursor.getLong(columnIndex));
                break;
            }
        }
    }

    return bundle;
}
 
Example 13
Source File: AudioUtil.java    From RhymeMusic with Apache License 2.0 4 votes vote down vote up
/**
 * 返回一个带有音乐信息的List
 * @param context 环境参数
 * @return 返回一个带有音乐信息的List
 */
public static ArrayList<Audio> getAudioList(Context context)
{
    ArrayList<Audio> audioList = new ArrayList<Audio>();
    ContentResolver resolver = context.getContentResolver();
    Cursor cursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            AUDIO_KEYS, null, null, null);

    for ( cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext() )
    {
        Bundle bundle = new Bundle();

        for ( int i = 0; i < AUDIO_KEYS.length; i++ )
        {
            final String key = AUDIO_KEYS[i];
            final int colIndex = cursor.getColumnIndex(key);
            final int type = cursor.getType(colIndex);

            switch (type)
            {
                case Cursor.FIELD_TYPE_BLOB:
                    break;

                case Cursor.FIELD_TYPE_FLOAT:
                    float fValue = cursor.getFloat(colIndex);
                    bundle.putFloat(key, fValue);
                    break;

                case Cursor.FIELD_TYPE_INTEGER:
                    int iValue = cursor.getInt(colIndex);
                    bundle.putInt(key, iValue);
                    break;

                case Cursor.FIELD_TYPE_NULL:
                    break;

                case Cursor.FIELD_TYPE_STRING:
                    String sValue = cursor.getString(colIndex);
                    bundle.putString(key, sValue);
                    break;
            }
        }

        Audio audio = new Audio(bundle);
        audioList.add(audio);
    }

    cursor.close();
    return audioList;
}
 
Example 14
Source File: FeatureUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Validate a feature row
 *
 * @param columns
 * @param featureRow
 */
private static void validateFeatureRow(String[] columns,
                                       FeatureRow featureRow) {
    TestCase.assertEquals(columns.length, featureRow.columnCount());

    for (int i = 0; i < featureRow.columnCount(); i++) {
        FeatureColumn column = featureRow.getTable().getColumns().get(i);
        GeoPackageDataType dataType = column.getDataType();
        TestCase.assertEquals(i, column.getIndex());
        TestCase.assertEquals(columns[i], featureRow.getColumnName(i));
        TestCase.assertEquals(i, featureRow.getColumnIndex(columns[i]));
        int rowType = featureRow.getRowColumnType(i);
        Object value = featureRow.getValue(i);

        switch (rowType) {

            case Cursor.FIELD_TYPE_INTEGER:
                TestUtils.validateIntegerValue(value, column.getDataType());
                break;

            case Cursor.FIELD_TYPE_FLOAT:
                TestUtils.validateFloatValue(value, column.getDataType());
                break;

            case Cursor.FIELD_TYPE_STRING:
                if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) {
                    TestCase.assertTrue(value instanceof Date);
                    Date date = (Date) value;
                    DateConverter converter = DateConverter.converter(dataType);
                    String dateString = converter.stringValue(date);
                    TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime());
                } else {
                    TestCase.assertTrue(value instanceof String);
                }
                break;

            case Cursor.FIELD_TYPE_BLOB:
                if (featureRow.getGeometryColumnIndex() == i) {
                    TestCase.assertTrue(value instanceof GeoPackageGeometryData);
                } else {
                    TestCase.assertTrue(value instanceof byte[]);
                }
                break;

            case Cursor.FIELD_TYPE_NULL:
                TestCase.assertNull(value);
                break;

        }
    }

    TestCase.assertTrue(featureRow.getId() >= 0);
}
 
Example 15
Source File: SqliteManagerPresenter.java    From SqliteManager with Apache License 2.0 4 votes vote down vote up
private
@NonNull
SqliteResponseData getSqliteResponseDataFromQuery(String query, String[] selectionArgs) {
    SqliteResponse sqliteResponse = mSqliteResponseRetriever.getData(query, selectionArgs);
    if (sqliteResponse.isQuerySuccess()) {
        try {
            Cursor cursor = sqliteResponse.getCursor();
            String[] selectedTableColumnNames = cursor.getColumnNames();
            int[] selectedTableColumnTypes = new int[selectedTableColumnNames.length];
            int columnCount = cursor.getColumnCount();
            List<SparseArray<Object>> valuesArray = new ArrayList<>(cursor.getCount());

            if (cursor.moveToFirst()) {
                do {
                    SparseArray<Object> columnValuePair = new SparseArray<>(columnCount);
                    for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
                        int fieldType = cursor.getType(columnIndex);
                        selectedTableColumnTypes[columnIndex] = fieldType;
                        if (fieldType == Cursor.FIELD_TYPE_NULL) {
                            columnValuePair.put(columnIndex, cursor.getString(columnIndex));
                        } else if (fieldType == Cursor.FIELD_TYPE_INTEGER) {
                            columnValuePair.put(columnIndex, cursor.getInt(columnIndex));
                        } else if (fieldType == Cursor.FIELD_TYPE_FLOAT) {
                            columnValuePair.put(columnIndex, cursor.getFloat(columnIndex));
                        } else if (fieldType == Cursor.FIELD_TYPE_STRING) {
                            columnValuePair.put(columnIndex, cursor.getString(columnIndex));
                        } else if (fieldType == Cursor.FIELD_TYPE_BLOB) {
                            columnValuePair.put(columnIndex, cursor.getBlob(columnIndex));
                        } else {
                            // never in this case
                            columnValuePair.put(columnIndex, cursor.getString(columnIndex));
                        }
                    }
                    valuesArray.add(columnValuePair);
                } while (cursor.moveToNext());
            }
            return new SqliteResponseData(columnCount, selectedTableColumnNames, selectedTableColumnTypes, valuesArray);
        } catch (Exception exception) {
            // sometimes cursor will not be null. when there are any constraints
            return new SqliteResponseData(exception);
        } finally {
            mSqliteDataRetriever.freeResources();
        }
    } else {
        mSqliteDataRetriever.freeResources();
        return new SqliteResponseData(sqliteResponse.getThrowable());
    }
}
 
Example 16
Source File: SQLiteConnection.java    From sqlite-android with Apache License 2.0 4 votes vote down vote up
private void bindArguments(PreparedStatement statement, Object[] bindArgs) {
    final int count = bindArgs != null ? bindArgs.length : 0;
    if (count != statement.mNumParameters) {
        String message = "Expected " + statement.mNumParameters + " bind arguments but "
            + count + " were provided.";
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            throw new SQLiteBindOrColumnIndexOutOfRangeException(message);
        } else {
            throw new SQLiteException(message);
        }
    }
    if (count == 0) {
        return;
    }

    final long statementPtr = statement.mStatementPtr;
    for (int i = 0; i < count; i++) {
        final Object arg = bindArgs[i];
        switch (getTypeOfObject(arg)) {
            case Cursor.FIELD_TYPE_NULL:
                nativeBindNull(mConnectionPtr, statementPtr, i + 1);
                break;
            case Cursor.FIELD_TYPE_INTEGER:
                nativeBindLong(mConnectionPtr, statementPtr, i + 1,
                        ((Number)arg).longValue());
                break;
            case Cursor.FIELD_TYPE_FLOAT:
                nativeBindDouble(mConnectionPtr, statementPtr, i + 1,
                        ((Number)arg).doubleValue());
                break;
            case Cursor.FIELD_TYPE_BLOB:
                nativeBindBlob(mConnectionPtr, statementPtr, i + 1, (byte[])arg);
                break;
            case Cursor.FIELD_TYPE_STRING:
            default:
                if (arg instanceof Boolean) {
                    // Provide compatibility with legacy applications which may pass
                    // Boolean values in bind args.
                    nativeBindLong(mConnectionPtr, statementPtr, i + 1, (Boolean) arg ? 1 : 0);
                } else {
                    nativeBindString(mConnectionPtr, statementPtr, i + 1, arg.toString());
                }
                break;
        }
    }
}
 
Example 17
Source File: HumanReadables.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static String describe(Cursor c) {
  if (c.isBeforeFirst()) {
    return "Cursor positioned before first element.";
  } else if (c.isAfterLast()) {
    return "Cursor positioned after last element.";
  }
  StringBuilder result = new StringBuilder("Row ").append(c.getPosition()).append(": {");
  String[] columns = c.getColumnNames();
  for (int i = 0; i < columns.length; i++) {
    result.append(columns[i]).append(":");
    int type = Cursor.FIELD_TYPE_STRING;
    if (Build.VERSION.SDK_INT > 10) {
      type = c.getType(i);
    }
    switch (type) {
      case Cursor.FIELD_TYPE_STRING:
        result.append("\"").append(c.getString(i)).append("\"");
        break;
      case Cursor.FIELD_TYPE_INTEGER:
        result.append(c.getLong(i));
        break;
      case Cursor.FIELD_TYPE_FLOAT:
        result.append(c.getDouble(i));
        result.append("f");
        break;
      case Cursor.FIELD_TYPE_NULL:
        result.append("null");
        break;
      case Cursor.FIELD_TYPE_BLOB:
        byte[] val = c.getBlob(i);
        result.append("[");
        for (int j = 0; j < 5 && j < val.length; j++) {
          result.append(val[j]);
          result.append(",");
        }
        if (5 < val.length) {
          result.append("... (").append(val.length - 5).append(" more elements)");
        }
        result.append("]");
        break;
      default:
        result.append("\"").append(c.getString(i)).append("\"");
        break;
    }
    result.append(", ");
  }
  result.append("}");
  return result.toString();
}
 
Example 18
Source File: ChromeFileProvider.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    Uri fileUri = getFileUriWhenReady(uri);
    if (fileUri == null) return null;

    // Workaround for a bad assumption that particular MediaStore columns exist by certain third
    // party applications.
    // http://crbug.com/467423.
    Cursor source = super.query(fileUri, projection, selection, selectionArgs, sortOrder);

    String[] columnNames = source.getColumnNames();
    String[] newColumnNames = columnNamesWithData(columnNames);
    if (columnNames == newColumnNames) return source;

    MatrixCursor cursor = new MatrixCursor(newColumnNames, source.getCount());

    source.moveToPosition(-1);
    while (source.moveToNext()) {
        MatrixCursor.RowBuilder row = cursor.newRow();
        for (int i = 0; i < columnNames.length; i++) {
            switch (source.getType(i)) {
                case Cursor.FIELD_TYPE_INTEGER:
                    row.add(source.getInt(i));
                    break;
                case Cursor.FIELD_TYPE_FLOAT:
                    row.add(source.getFloat(i));
                    break;
                case Cursor.FIELD_TYPE_STRING:
                    row.add(source.getString(i));
                    break;
                case Cursor.FIELD_TYPE_BLOB:
                    row.add(source.getBlob(i));
                    break;
                case Cursor.FIELD_TYPE_NULL:
                default:
                    row.add(null);
                    break;
            }
        }
    }

    source.close();
    return cursor;
}
 
Example 19
Source File: DebugHelper.java    From XMiTools with GNU General Public License v3.0 4 votes vote down vote up
public static void printCursor(Uri uri, Cursor c) {
    XLog.d("%s", uri.toString());
    if (c == null) {
        return;
    }
    boolean hasNext = c.moveToNext();
    if (!hasNext) {
        return;
    }

    int columnCount = c.getColumnCount();
    String[] columnNames = c.getColumnNames();
    int[] columnTypes = new int[columnCount];
    for (int i = 0; i < columnCount; i++) {
        columnTypes[i] = c.getType(i);
    }
    c.moveToPrevious();
    while (c.moveToNext()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < columnCount; i++) {
            Object value = null;
            int columnType = columnTypes[i];
            if (columnType == Cursor.FIELD_TYPE_INTEGER) {
                c.getInt(i);
            }
            switch (columnType) {
                case Cursor.FIELD_TYPE_INTEGER:
                    value = c.getInt(i);
                    break;
                case Cursor.FIELD_TYPE_BLOB:
                    value = c.getBlob(i);
                    break;
                case Cursor.FIELD_TYPE_FLOAT:
                    value = c.getFloat(i);
                    break;
                case Cursor.FIELD_TYPE_STRING:
                    value = c.getString(i);
                    break;
                default:
                case Cursor.FIELD_TYPE_NULL:
                    break;
            }
            sb.append(columnNames[i]).append(" = ").append(value).append(", ");
        }
        sb.append("\n");
        XLog.d("%s", sb.toString());
    }
}
 
Example 20
Source File: FullBackupExporter.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private static int exportTable(@NonNull   String table,
                               @NonNull   SQLiteDatabase input,
                               @NonNull   BackupFrameOutputStream outputStream,
                               @Nullable  Predicate<Cursor> predicate,
                               @Nullable  Consumer<Cursor> postProcess,
                                          int count)
    throws IOException
{
  String template = "INSERT INTO " + table + " VALUES ";

  try (Cursor cursor = input.rawQuery("SELECT * FROM " + table, null)) {
    while (cursor != null && cursor.moveToNext()) {
      EventBus.getDefault().post(new BackupEvent(BackupEvent.Type.PROGRESS, ++count));

      if (predicate == null || predicate.test(cursor)) {
        StringBuilder                     statement        = new StringBuilder(template);
        BackupProtos.SqlStatement.Builder statementBuilder = BackupProtos.SqlStatement.newBuilder();

        statement.append('(');

        for (int i=0;i<cursor.getColumnCount();i++) {
          statement.append('?');

          if (cursor.getType(i) == Cursor.FIELD_TYPE_STRING) {
            statementBuilder.addParameters(BackupProtos.SqlStatement.SqlParameter.newBuilder().setStringParamter(cursor.getString(i)));
          } else if (cursor.getType(i) == Cursor.FIELD_TYPE_FLOAT) {
            statementBuilder.addParameters(BackupProtos.SqlStatement.SqlParameter.newBuilder().setDoubleParameter(cursor.getDouble(i)));
          } else if (cursor.getType(i) == Cursor.FIELD_TYPE_INTEGER) {
            statementBuilder.addParameters(BackupProtos.SqlStatement.SqlParameter.newBuilder().setIntegerParameter(cursor.getLong(i)));
          } else if (cursor.getType(i) == Cursor.FIELD_TYPE_BLOB) {
            statementBuilder.addParameters(BackupProtos.SqlStatement.SqlParameter.newBuilder().setBlobParameter(ByteString.copyFrom(cursor.getBlob(i))));
          } else if (cursor.getType(i) == Cursor.FIELD_TYPE_NULL) {
            statementBuilder.addParameters(BackupProtos.SqlStatement.SqlParameter.newBuilder().setNullparameter(true));
          } else {
            throw new AssertionError("unknown type?"  + cursor.getType(i));
          }

          if (i < cursor.getColumnCount()-1) {
            statement.append(',');
          }
        }

        statement.append(')');

        outputStream.write(statementBuilder.setStatement(statement.toString()).build());

        if (postProcess != null) postProcess.accept(cursor);
      }
    }
  }

  return count;
}