How to use Country Picker in Android

Posted By : Ankita Singh | 10-Apr-2017

CountryCodePicker will help users to search and select a country and retrieve selected country's country name,code,currency and dial code.For supporting international numbers in our app we must have to include library

"compile 'com.hbb20:ccp:1.7.2'"
in your app.

After that add the below given countrypicker in the xml file where you want to add this in UI.

    app:defaultCode="91" />

after this do the findviewbyid in the activity class and then add the following code to the Java class file and you will easily get the country code -

String countryCodeAndroid = "91";
CountryCodePicker ccp;
protected void onCreate(@Nullable Bundle savedInstanceState) {
    ccp.setOnCountryChangeListener(new CountryCodePicker.OnCountryChangeListener() {
        public void onCountrySelected() {
            countryCodeAndroid = ccp.getSelectedCountryCode();
            Log.d("Country Code", countryCodeAndroid);

after getting country code use it according to yourself.


The local file uses a json file of the country codes and parse it to get the arraylist of the country code with dial code and country names.This library is very god because it contain the search option user can easily search the country name just by typing the name in the edittext .

Request for Proposal

Recaptcha is required.

Sending message..