Manually set the locale of the application in Android

Android provides a flexible support of localization that system will load different resources according the locale of the current system configuration. However, sometimes we want to manually change the locale of our application especially for our Hong Kong market that people may want to have Chinese locale application in a English system configuration.

To do this, we can set the configuration of the application using the following code:

Header:

import android.content.res.Resources;
import java.util.Locale;


Resources res = getResources();
Configuration newConfig = new Configuration(res.getConfiguration());
// newConfig.locale = Locale.TRADITIONAL_CHINESE;
newConfig.locale = Locale.ENGLISH;
res.updateConfiguration(newConfig, null);