Gilian Marques
Gilian Marques

Reputation: 547

Android: Get user language in ISO 639 alpha-2 code(en, pt, jp...)

I'm trying to get user language with two-letters but no success until here.

Use Locale.getDefault().getISO3Language(); returns code with three digits (eng, por, jap).

Use substring method to cut does not work for all codes, so what's the solution?

Upvotes: 6

Views: 2333

Answers (1)

Vikasdeep Singh
Vikasdeep Singh

Reputation: 21766

Instead of getISO3Language(), use getLanguage() and you will get user language like en, ja, pt etc.

Locale.getDefault().getLanguage();

Checkout official documentation for more information about getLanguage()

Upvotes: 8

Related Questions