I’m grabbing the data of the database. If integer I can use getInt
, If String I can use getString
. But BigDecimal
I don’t know what to use…
Please Help. Thanks in advance!
while (cursor.moveToNext()) { int id = cursor.getInt(0); String txnno = cursor.getString(1); String name = cursor.getString(2); String txndate = cursor.getString(3); BigDecimal amount = cursor.getDouble(4); String description1 = cursor.getString(5); String createddate = cursor.getString(7); mList.add(new Model(id, txnno, name, txndate, amount, description1, createddate)); }
Advertisement
Answer
Use BigDecimal.valueOf(double val)
:
BigDecimal amount = BigDecimal.valueOf(cursor.getDouble(4));