title: Android Studio: Try to change Background based on Shared Pref, but reset to default background when force close
body: <p>So, i try to change Background based on Shared Preference onCreate like this:</p>
  
  <pre><code>**strong text**
  @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_setting);
          prefManager = new PrefManager(this);
          String imagename = prefManager.getBg();
          if (imagename=="1") {
              RelativeLayout settinglin = (RelativeLayout) findViewById(R.id.settinglin);
              settinglin.setBackgroundResource(R.drawable.lginbg);
          } else if(imagename=="2") {
              RelativeLayout settinglin = (RelativeLayout) findViewById(R.id.settinglin);
              settinglin.setBackgroundResource(R.drawable.lginbgload);
  etc...
  </code></pre>
  
  <p>It work fine for this function but the problem is, when the application force close it always return the background picture to the default background (in layout)
  for example:</p>
  
  <pre><code>android:background="@drawable/lginbg"
  </code></pre>
  
  <p>I check the value of my shared Preference is not reset when force close (so the problem isn't in shared preference)</p>
  
  <p>Can someone help me please with this problem</p>