Proszę zwrócić uwagę na komentarze:
public Cursor fetchAllItemsInExpenses() {
return SQLDb.query(TABLE_EXPENSES, new String[] {KEY_ROWID, EXPENSE_CATEGORY, EXPENSE_VALUE, EXPENSE_DATE}, null, null, null, null, null);
}
private void fillData() {
Cursor itemCursor = db.fetchAllItemsInExpenses();
startManagingCursor(itemCursor);
/dwie poniższe linie dodałem chcąc formatować daną z tabeli do formatu 0.00 i najwyraźniej nie da się tego zrobić w ten sposób bo wywala ForceClose (bez tych 2 linii program działa, wczytuje mi do listy dane FLOAT z tabeli)
NumberFormat formatter = new DecimalFormat(".00");
String value = formatter.format(CfmDbAdapter.EXPENSE_VALUE);
String[] from = new String[]{CfmDbAdapter.EXPENSE_CATEGORY, value, CfmDbAdapter.EXPENSE_DATE};
int[] to = new int[]{R.id.expense_category_name, R.id.expense_value, R.id.expense_date};
SimpleCursorAdapter items = new SimpleCursorAdapter(this, R.layout.expenses_list_item, itemCursor, from, to);
setListAdapter(items);
}
Szukam poprawnego sposobu na sformatowanie wyświetlanych w liście danych do formatu 0.00 (a najlepiej walutowego)
Z tabeli dostawałem float i to najwyraźniej jest typ wymagany przez kursor (nie wiem w sumie czemu, pozostale pobierane typy to string i date).