How to get currency according to country code in Android?

Viewed 53

In below code I can get country code (2 alpha). Is it possible to get currency according to the country code? If yes please tell me how? I don't want to add any runtime permission for this app.

final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final String simCountry = tm.getSimCountryIso();
if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
    String country_code = simCountry.toLowerCase(Locale.US);
    //return result - "in". (for India)
    //here I want to get the currency according to the country code
}
1 Answers

Hello My Friend You Can Be Use (Locale And Currency) Classes To Find Currency Code .

Like :

final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final String simCountry = tm.getSimCountryIso();
if (simCountry != null && simCountry.length() == 2) { 
    String country_code = simCountry.toLowerCase(Locale.US);
    Currency.getInstance(new Locale("", country_code)).getCurrencyCode()
}


    //  Currency.getInstance(new Locale("", "us")).getCurrencyCode() -- This Return USD
    //  Currency.getInstance(new Locale("", "in")).getCurrencyCode() -- This Retrun INR
Related