-1

How to get country code like +91 for India and +1 for US.

This is my code,

 TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
 String CountryID= manager.getSimCountryIso().toUpperCase();

Above code shows IN. Please help me.

K Neeraj Lal
  • 6,768
  • 3
  • 24
  • 33
Aveen
  • 11
  • 1

2 Answers2

0

I hope this will be helpful.

String locale = context.getResources().getConfiguration().locale.getCountry();
0

You can't get the prefix automatically from the sdk.

I had a similar problem and I solved by creating pre-populated json and reading it (but is not the best way)

I suggest you to read this post with a quickly and efficient solution.

Community
  • 1
  • 1
appersiano
  • 2,670
  • 22
  • 42