The checked answer has deprecated code. You need to implement this:
String locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
locale = context.getResources().getConfiguration().getLocales().get(0).getCountry();
} else {
locale = context.getResources().getConfiguration().locale.getCountry();
}