List of usage examples for android.database DatabaseUtils cursorStringToContentValues
public static void cursorStringToContentValues(Cursor cursor, String field, ContentValues values)
From source file:com.money.manager.ex.reports.CategoriesReportFragment.java
private CategorySub getCategoryFromSelectedItem(ListView l, int position) { // Reading item from the list view, not adapter! Object item = l.getItemAtPosition(position); if (item == null) return null; Cursor cursor = (Cursor) item; ContentValues values = new ContentValues(); DatabaseUtils.cursorIntToContentValues(cursor, ViewMobileData.CATEGID, values); DatabaseUtils.cursorStringToContentValues(cursor, ViewMobileData.Category, values); DatabaseUtils.cursorIntToContentValues(cursor, ViewMobileData.SubcategID, values); DatabaseUtils.cursorStringToContentValues(cursor, ViewMobileData.Subcategory, values); CategorySub result = new CategorySub(); result.categId = values.getAsInteger(ViewMobileData.CATEGID); result.categName = values.getAsString(ViewMobileData.Category); result.subCategId = values.getAsInteger(ViewMobileData.SubcategID); result.subCategName = values.getAsString(ViewMobileData.Subcategory); return result; }
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;/*from w w w . j ava 2 s. co 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; }