title: Uninstalled my app. And when reinstalled app values don't change
body: <p>My application is a tycoon game in which the user taps a button in order to increase his score and so he buys upgrades to increase the amount of score he has quickly. </p>
  
  <p>Well, just out of curiosity I uninstalled my app and the reinstalled it through Android Studio, when I ran it the app didn't work. I tried tapping the button to increase the score, but still it didn't increase. To save the users score I use <strong>SharedPreferences</strong> after they close the app. Maybe that has something to do with it?</p>
  
  <p>Android Manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.navjeevenmann.mytycoon"&gt;
  
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".MainActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity android:name=".SecondActivity" /&gt;
      &lt;activity android:name=".ThirdActivity"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Main Activity:</p>
  
  <pre><code>package com.example.navjeevenmann.mytycoon;
  
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.os.Handler;
  import android.preference.PreferenceManager;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.ImageButton;
  import android.widget.TextView;
  
  import static com.example.navjeevenmann.mytycoon.R.id.textView;
  
  
  public class MainActivity extends AppCompatActivity {
  private ImageButton myButton;
  private int Counter;
  private ImageButton autoclick;
  private TextView myTextView;
  Handler handler = new Handler();
  private int add;
  private TextView myAddView;
  private ImageButton singleclick;
  private int Singleadd = 1;
  private ImageButton money;
  private boolean[] array;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      setContentView(R.layout.activity_main);
      getSupportActionBar().hide();
  
      super.onCreate(savedInstanceState);
      Bundle bundle = getIntent().getExtras();
      if (bundle != null) {
          if (bundle.containsKey("Count")) {
              Counter = bundle.getInt("Count");
          }
          if (bundle.containsKey("Add")) {
              add = bundle.getInt("Add");
          }
          if (bundle.containsKey("Single")) {
              Singleadd = bundle.getInt("Single");
          }
          if (bundle.containsKey("array")) {
              array = bundle.getBooleanArray("array");
          }
      }
      add = getaddvalue();
      Counter = getvalue();
      Singleadd = getSinglevalue();
  
      money = (ImageButton) findViewById(R.id.imageButton2);
      myButton = (ImageButton) findViewById(R.id.button);
      autoclick = (ImageButton) findViewById(R.id.autoclick);
      singleclick = (ImageButton) findViewById(R.id.singleclick);
      myTextView = (TextView) findViewById(textView);
      myAddView = (TextView) findViewById(R.id.textView2);
      myButton.setBackgroundColor(0);
      myButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Counter = ButtonCounter(Counter);
          }
      });
      autoclick.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent intent = new Intent(getApplicationContext(), SecondActivity.class);
              intent.putExtra("Count", Counter);
              intent.putExtra("Add", add);
              intent.putExtra("Single", Singleadd);
              intent.putExtra("array", array);
  
              startActivity(intent);
          }
  
      });
  
      singleclick.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent intent = new Intent(getApplicationContext(), ThirdActivity.class);
              intent.putExtra("Count", Counter);
              intent.putExtra("Single", Singleadd);
              intent.putExtra("Add", add);
              intent.putExtra("array", array);
              startActivity(intent);
          }
      });
  
  }
  
  public void onStop() {
      super.onStop();
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
      SharedPreferences.Editor editor = prefs.edit();
      editor.putInt("usermoney", Counter);
      editor.putInt("Auto", add);
      editor.putInt("Single", Singleadd);
      editor.commit();
  }
  
  public int getvalue() {
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      return prefs.getInt("usermoney",0);
  }
  
  public int getaddvalue() {
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      return prefs.getInt("Auto", 0);
  }
  
  public int getSinglevalue() {
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      return prefs.getInt("Single", 0);
  }
  
  public void onResume() {
      super.onResume();
  
      handler.postDelayed(new Runnable() {
          @Override
          public void run() {
              Counter = AutoCounter(Counter, add);
              handler.postDelayed(this, 1000);
          }
      }, 1000);
  
      handler.postDelayed(new Runnable() {
          @Override
          public void run() {
              Display(Counter, add);
              handler.postDelayed(this, 1);
          }
      }, 50);
  }
  
  
  public int ButtonCounter(int Counter) {
      Counter += Singleadd;
      return Counter;
  }
  
  public int AutoCounter(int Counter, int add) {
      Counter = Counter + add;
      return Counter;
  }
  
  public void Display(int Counter, int add) {
      String money = String.valueOf(Counter);
      myTextView.setText(":" + money);
      myAddView.setText("$" + add + "/Per Second");
  
  }
  
  }
  </code></pre>
  
  <p>Thank you</p>