Retrieve currency info by country code #92
-
Hi, thanks for the library, it looks awesome and has a really nice API for the picker. Im using the currency picker to set a string in shared preferences based on country code, how do I derive currency information at runtime for other currency fields when ive set a country code in shared preferences (android) (as an example)? - e.g. id need to retrieve symbol, decimal seperator etc? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@tom-NI Thank you for your positive feedback! I'm glad you find the library useful. To retrieve currency information at runtime based on a country code you can use the Here's an example of how you can achieve this: // Assuming you have the country code stored in SharedPreferences
String countryCode = // The country code from SharedPreferences;
// Use CurrencyService to find the currency information by code
Currency currency = CurrencyService().findByCode(countryCode);
// Now you can access various properties of the currency, such as symbol and decimal separator
String currencySymbol = currency.symbol;
String decimalSeparator = currency.decimalSeparator;
// Use the retrieved information as needed in your application
Check other functions provided by If you have any more questions or need further clarification, please let me know. |
Beta Was this translation helpful? Give feedback.
@tom-NI Thank you for your positive feedback! I'm glad you find the library useful.
To retrieve currency information at runtime based on a country code you can use the
CurrencyService().findByCode("EUR");
.Here's an example of how you can achieve this: