1. Are you ready for the Galaxy S20? Here is everything we know so far!

Shared Preference

Discussion in 'Android Development' started by AlexeyS, Jul 10, 2017.

  1. AlexeyS

    AlexeyS Newbie
    Thread Starter

    Hello, i have a question about shared preferences. In my app, user can choose language in settings. How can i retrieve the language?

    i write the next code in onCreate:

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String myPref = prefs.getString("language", "empty");
    if mypref.equals("empty") {
    ... todo

    But if the user change language during using app. I have to write the same code in onResume, to get the updated values?

    Thank you

    1. Download the Forums for Android™ app!



Share This Page