Configuration `locale` variable is deprecated - Android : <p>I use this code to set the default language manually in multiple languages app:</p>

<pre><code>public static void setLanguage(Context context, String languageCode){
    Locale locale = new Locale(languageCode);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;  // Deprecated !!
    context.getApplicationContext().getResources().updateConfiguration(config,
            context.getResources().getDisplayMetrics());
}
</code></pre>

<p>so now we cant set locale by config.locale is deprecated because the variable is going to be removed in API 24.</p>

<p>So i saw that the alternative is to set:</p>

<p>config.setLocales();</p>

<p>locale</p>

<blockquote>
  <p>Added in API level 1 </p>
  
  <p><strong>Locale</strong> locale</p>
  
  <p>This field was deprecated in API
  level 24. Do not set or read this directly. Use getLocales() and
  setLocales(LocaleList). If only the primary locale is needed,
  getLocales().get(0) is now the preferred accessor.</p>
  
  <p>Current user preference for the locale, corresponding to locale
  resource qualifier.</p>
</blockquote>

<p>I noticed also that there is <code>setLocale(Locale)</code> as well but for api 17 and above</p>

<p>I checked the setLocales(LocalList) documentation and it is marked in grey as if it is also deprecated !</p>

<p>so what can be solution for this !?</p>
