getPreferredLocale
Returns the user's currently preferred application locale.
This function retrieves the application-specific locale set via setLanguagePreference. If no application locale is set, it falls back to the system default locale.
Settings maps this locale to its Language selection.
Usage for Formatting
val locale = getPreferredLocale()
val formattedDate = SimpleDateFormat("dd MMMM yyyy", locale).format(Date())
val formattedNumber = NumberFormat.getCurrencyInstance(locale).format(price)Content copied to clipboard
Locale Information
val locale = getPreferredLocale()
val languageCode = locale.language // "en", "es", "fr", etc.
val countryCode = locale.country // "US", "ES", "FR", etc.
val displayName = locale.displayLanguage // "English", "Español", "Français"Content copied to clipboard
Return
The user's preferred Locale, or system default if none is set