How to get currency symbol by currency name?

I want get Currency symbol (like $ or £) by currency name (like USD or EUR).

For English(US) I can get symbol (if English(US) set as language on device):

  • Should I use AlarmManager or Handler?
  • How to create UUID from string in android
  • Error: Stopping ADB Server Failed (Code -1) {Installing API's - Android SDK}
  • Is PhoneGap a good choice for App Development?
  • Align left edge to center - RelativeLayout
  • How to save and retrieve Date in SharedPreferences
  • Currency currency = Currency.getInstance(Locale.getDefault());
    String symbol = currency.getSymbol()); // $
    

    How can I get symbol for currency by currency name using android tools –

    someMethod (String currCode) { // currCode - USD, EUR, UAH
        return currSymbol;       // $...
    }
    

  • android communication between two applications
  • Android - What is a secondary progress in ProgressBar?
  • Are there any Android Drawable designers?
  • CMUSphinx PocketSphinx - Recognize all (or large amount) of words
  • Split GIF into frames
  • Is there a listener for when the WebView displays it's content?
  • 4 Solutions collect form web for “How to get currency symbol by currency name?”

    You can try some like this:

    public class MainActivity extends AppCompatActivity {
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Utils.getCurrencySymbol(Currency.getInstance(Locale.US).getCurrencyCode());
            Utils.getCurrencySymbol(Currency.getInstance(Locale.JAPAN).getCurrencyCode());
            Utils.getCurrencySymbol(Currency.getInstance(Locale.UK).getCurrencyCode());
    
            //for your case that you want to get Euro symbol because France are with Euro symnol    
            Utils.getCurrencySymbol(Currency.getInstance(Locale.FRANCE).getCurrencyCode());
            //you can get symbol also if you write string of your desired currency
            Utils.getCurrencySymbol("INR");
    
    
        }
    
    
        static class Utils {
            public static SortedMap<Currency, Locale> currencyLocaleMap;
    
            static {
                currencyLocaleMap = new TreeMap<Currency, Locale>(new Comparator<Currency>() {
                    public int compare(Currency c1, Currency c2) {
                        return c1.getCurrencyCode().compareTo(c2.getCurrencyCode());
                    }
                });
                for (Locale locale : Locale.getAvailableLocales()) {
                    try {
                        Currency currency = Currency.getInstance(locale);
                        currencyLocaleMap.put(currency, locale);
                    } catch (Exception e) {
                    }
                }
            }
    
    
            public static String getCurrencySymbol(String currencyCode) {
                Currency currency = Currency.getInstance(currencyCode);
                System.out.println(currencyCode + ":-" + currency.getSymbol(currencyLocaleMap.get(currency)));
                return currency.getSymbol(currencyLocaleMap.get(currency));
            }
    
        }
    }
    

    I believe java.util.currency is the class you need, call getSymbol to get symbol from currency name

    http://developer.android.com/reference/java/util/Currency.html

    Currency symbol depends on location. The same $ sign means different currencies in US and Australia. So, to get the correct symbol you have to provide the Locale instance. Otherwise, a default locale will be applied, which will result in different values for different devices.

        Locale uk = new Locale("en", "GB");
        Currency pound = Currency.getInstance("GBP");
        pound.getSymbol(uk);
    

    I’ve solved this problem to create a Map which has the key is the currency code and the value is the symbol.

    public final Map<String, String> CURRENCIES= new HashMap<String, String>(){
            {
                put("EUR","€");
                put("USD","$");
                ...
            }
    }; 
    

    Then, you can get the symbol by using Locale, like this.

    Currency currency = Currency.getInstance(Locale.getDefault());
    String symbol = CURRENCIES.get(currency.getCurrencyCode());
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.