List of usage examples for android.database DatabaseUtils cursorDoubleToCursorValues
public static void cursorDoubleToCursorValues(Cursor cursor, String field, ContentValues values)
From source file:com.money.manager.ex.common.AllDataListFragment.java
private Money getTotalFromCursor(Cursor cursor) { Money total = MoneyFactory.fromString("0"); int originalPosition = cursor.getPosition(); AllDataAdapter adapter = getAllDataAdapter(); CurrencyService currencyService = new CurrencyService(getContext()); int baseCurrencyId = currencyService.getBaseCurrencyId(); ContentValues values = new ContentValues(); int currencyId; Money amount;/* w w w. j a v a2s . c o m*/ Money converted; String transType; TransactionTypes transactionType; cursor.moveToPosition(Constants.NOT_SET); while (cursor.moveToNext()) { values.clear(); // Read needed data. DatabaseUtils.cursorStringToContentValues(cursor, adapter.TRANSACTIONTYPE, values); DatabaseUtils.cursorIntToContentValues(cursor, adapter.CURRENCYID, values); DatabaseUtils.cursorIntToContentValues(cursor, adapter.TOCURRENCYID, values); DatabaseUtils.cursorDoubleToCursorValues(cursor, adapter.AMOUNT, values); DatabaseUtils.cursorDoubleToCursorValues(cursor, adapter.TOAMOUNT, values); transType = values.getAsString(adapter.TRANSACTIONTYPE); transactionType = TransactionTypes.valueOf(transType); if (transactionType.equals(TransactionTypes.Transfer)) { currencyId = values.getAsInteger(adapter.TOCURRENCYID); amount = MoneyFactory.fromString(values.getAsString(adapter.TOAMOUNT)); } else { currencyId = values.getAsInteger(adapter.CURRENCYID); amount = MoneyFactory.fromString(values.getAsString(adapter.AMOUNT)); } converted = currencyService.doCurrencyExchange(baseCurrencyId, amount, currencyId); total = total.add(converted); } cursor.moveToPosition(originalPosition); return total; }