Problem with getString on shared preferences

  • Replies:0
  • OpenNot stickiedUnanswered

Jan 6, 2013 8:07:31 PM via Website

Hi
I cant get this if working correctly

1SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
2 ustawienia_wybrana_gra3=sharedPrefs.getString("ustawienia_wybrana_gra","");
3 if (ustawienia_wybrana_gra3==(String) "1") ustawienia_wybrana_gra2=getString(R.string.ustawienia_gra_1_nazwa);
4 else ustawienia_wybrana_gra2=getString(R.string.ustawienia_gra_2_nazwa);
5
6
7 StringBuilder builder = new StringBuilder();
8 builder.append("\nWybrana gra:" + ustawienia_wybrana_gra2 + "\n-"+(sharedPrefs.getString("ustawienia_wybrana_gra",""))+"-"+ustawienia_wybrana_gra3.length());

It always runs ELSE statment never IF, regards of the shared preference value witch is 1 (see screen below)

What I'm doing wrong?