set Persian Locale to Context - Android Internationalization

Android examples for Internationalization:Locale

Description

set Persian 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 Locale setPersianLocale(Context context) {
        Locale defaultLocale = Locale.getDefault();
        Locale locale = new Locale("fa");
        Locale.setDefault(locale);
        Configuration configuration = new Configuration();
        configuration.locale = locale;//ww w .j  a v  a2s. co  m
        context.getResources().updateConfiguration(configuration,
                context.getResources().getDisplayMetrics());
        return defaultLocale;
    }
}

Related Tutorials