title: Get current local for currency
body: <p>I have an Android app that requires the use of currency, dependent on the country, but I'm having some trouble getting the right currency.</p>
  
  <p>My first approach was to do has following</p>
  
  <pre><code>NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.getDefault());
  String price = nf.format(Double.parseDouble(priceEditText.getText().toString()));
  </code></pre>
  
  <p>The problems with this was that I'm currently in Portugal but, because my phone is in English(US), the default currency is dollars and what I was expecting was euros. On the other hand it also make me wonder what would happen if, for example, I'm in some country like Mexico where there are no specific device default language.</p>
  
  <p>Then I went online and found a way to get the country code using the telphone service using something like this.</p>
  
  <pre><code>TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
  String countryCode = tm.getSimCountryIso();
  </code></pre>
  
  <p>This code works great and gives me exactly what I want but, when I try to extract a currency out of it, some strange symbol appears because the currency is set to XXX.</p>
  
  <pre><code>TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
  String countryCode = tm.getSimCountryIso();
  
  Locale locale = new Locale(countryCode.toUpperCase());
  
  NumberFormat nf = NumberFormat.getCurrencyInstance(locale);
  String price = nf.format(Double.parseDouble(priceEditText.getText().toString()));
  Log.d("Currency", "" + nf.getCurrency()); // prints : XXX
  </code></pre>
  
  <p>Finally my question is, how is the best way to get the currency based on the device locale? This without using battery consuming techniques like GPS.</p>
  
  <p>Thanks.</p>