set Default Locale to Context - Android Internationalization

Android examples for Internationalization:Locale

Description

set Default Locale to Context

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.res.Configuration;
import java.util.Locale;

public class Main {
    public static void setDefaultLocale(Context context,
            Locale defaultLocale) {
        Locale.setDefault(defaultLocale);
        Configuration configuration = new Configuration();
        configuration.locale = defaultLocale;
        context.getResources().updateConfiguration(configuration,
                context.getResources().getDisplayMetrics());
    }//  w  ww .  j  a  va 2s  . com
}

Related Tutorials