-2

I'm new to Android so please, explain me, how to use BigDecimal in API level 16, because using this line:

BigDecimal currentNumber = new BigDecimal(String "0.0");

results in an error, Call requires api level 24.

  • Why not just upgrade to 24? – Mureinik Aug 10 '16 at 16:44
  • Probably, because Samsung didn't make any updates for Galaxy Note 2 for years, so it runs Android 4.4. Making an app, that I can't use would be kind of dumb. – Георг Мосин Aug 10 '16 at 17:29
  • I dont see what you mean. Android uses java. You can just use normal strings and bigdecimals independant of your api level I think. Make sure you are not using any jdk 7 features and some jdk 6 features are only supported after lvl 19. But bigdecimal is jdk 5 – HopefullyHelpful Aug 28 '16 at 20:42
  • Also you have a syntac error as far as I can tell. leave the "String" out or use new String("0.0"). – HopefullyHelpful Aug 28 '16 at 20:45

2 Answers2

5

import this

java.math.BigDecima(Added in API 1)

instead of this

android.icu.math.BigDecimal(Added in API 24)
Sujit Yadav
  • 2,697
  • 1
  • 15
  • 17
2

you are constructing the object wrong... BigDecimal is available since API1

you need to do:

BigDecimal currentNumber = new BigDecimal("0.0");

Note that I removed the unnecessary String Class just pass the value between quotes...

Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97