Force app to read from layout-ar

android, layout

Solution

You can force a different locale like this:

protected static void setLocale(final Context ctx, final String lang)
{
    final Locale loc = new Locale(lang);
    Locale.setDefault(loc);
    final Configuration cfg = new Configuration();
    cfg.locale = loc;
    ctx.getResources().updateConfiguration(cfg, null);
}

In your case, use it so

setLocale(getApplicationContext(), "ar")

This will take the values from your "ar" folders (drawables-ar, values-ar, layout-ar, ...)

Problem

I am asking if There is a way to force the android application to read from Arabic layout folders and Arabic values folder whatever the device language ?

Original source