Мое приложение поддерживает несколько языков. У меня есть сервис, который выбирает местоположение пользователя и сохраняет его в SharedPreference. Однако сохраненные значения местоположения пользователя имеют язык в зависимости от локали приложения. Геокодер возвращает данные на языке локали. Как установить языковой стандарт Engli sh при сохранении данных в SharedPreference.
private void setUserLocation(double latitude, double longitude){
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(this, Locale.getDefault());
try{
addresses = geocoder.getFromLocation(latitude, longitude, 1);// Here 1 represent max location result to returned, by documents it recommended 1 to 5
} catch (Exception e){
e.printStackTrace();
return;
}
final SharedPreferences sharedPref = getSharedPreferences(
Constant.app_pref, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(Constant.user_address, addresses.get(0).getAddressLine(0));
editor.putString(Constant.user_city, addresses.get(0).getLocality());
editor.putString(Constant.user_state, addresses.get(0).getAdminArea());
editor.putString(Constant.user_country, addresses.get(0).getCountryName());
editor.putString(Constant.user_postal_code, addresses.get(0).getPostalCode());
editor.putString(Constant.user_known_name, addresses.get(0).getFeatureName());
Log.e("Country----", addresses.get(0).getCountryName());
editor.apply();
}