Android examples for java.util:Locale
Get user config locale.
import java.util.Locale; import android.content.Context; import android.content.res.Configuration; import android.provider.Settings; public class Main { /**//from www . j ava 2 s . com * Get user config locale. Use default locale if failed. */ private static Locale getLocale(Context context) { Locale locale = null; try { Configuration configuration = new Configuration(); configuration.setToDefaults(); Settings.System.getConfiguration(context.getContentResolver(), configuration); if (configuration != null) { locale = configuration.locale; } } catch (Exception e) { } if (locale == null) { locale = Locale.getDefault(); } return locale; } }