I am trying to store currency values in sqlite database in android. I don't think so that int
will be used here. I have heard that Bigdecimal
can be used. If anyone can tell me the way it should be used to send values to sqlite database.
Store the BigDecimal as a String.
You can use the toPlainString() method.
BigDecimal b = new BigDecimal();
String s = b.toPlainString();
Then when you pull it from the database you can create a new BigDecimal.
BigDecimal c = new BigDecimal(String s)
Believe it or not SQLite 3.0 stores all data types as strings even if you say it should be an Integer. Take a look at this web page from the official SQLite website and scroll down to the "Manifest Typing and BLOB Support" section. It talks about how it will let you store strings in columns of other types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With