Android Is it possible to get the currency code of the country, where the user and device is?
android, currency, java
Solution
As this piece of code might be helpfull for you ,
public class CurrencyTest {
public static void main(String[] args) throws Exception {
Locale defaultLocale = Locale.getDefault();
displayCurrencyInfoForLocale(defaultLocale);
Locale swedishLocale = new Locale("sv", "SE");
displayCurrencyInfoForLocale(swedishLocale);
}
public static void displayCurrencyInfoForLocale(Locale locale) {
System.out.println("Locale: " + locale.getDisplayName());
Currency currency = Currency.getInstance(locale);
System.out.println("Currency Code: " + currency.getCurrencyCode());
System.out.println("Symbol: " + currency.getSymbol());
System.out.println("Default Fraction Digits: " + currency.getDefaultFractionDigits());
System.out.println();
}
}
Problem
Is it possible to get the currency code of the country, where the user and device is. i want to set the country code of the present country of the user as default country. Do we have a solution for this in android ?