How do I get the country code of a user on Android?

You can try the following function. It's returning your country ISO code:

TelephonyManager telephonyManager = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);

        public String getSimCountryIso() {

    return telephonyManager.getSimCountryIso();

}
Add permission below into your AndroidManifest.xml file
< uses-permission android:name="android.permission.READ_PHONE_STATE"/>