Problem with Sharedpreference Not getting previous number

the problem is when I reopen the app I don't see the previous number which is been there before closing the app


int GoalsFor1 = 0;

public Button btn;

TextView quantityTextView;

protected void onCreate(Bundle savedInstanceState) {

// declaring Button & textView

    btn = findViewById(;
    quantityTextView= findViewById(;

// I think the problem is here, but i don't know what exactly

    SharedPreferences sp = getSharedPreferences("Goal", MODE_PRIVATE);
    int goal_sp = sp.getInt("GOALP1_sp",0);

    btn.setOnClickListener(new View.OnClickListener() {

// onClick

        public void onClick(View view) {
            GoalsFor1 += 1;
            quantityTextView.setText("" + GoalsFor1);

            SharedPreferences sp = getSharedPreferences("Goal", MODE_PRIVATE);
            SharedPreferences.Editor editor = sp.edit();
            editor.putInt("GOALP1_sp", GoalsFor1);