Q:

Why is my integer always zero?

I am embarrassed to have such a simple question, but I just don't know what I'm doing wrong. I'm trying to have a level unlock after score 20. The first time the level gets unlocked, I want to give the user a message saying "level unlocked". I do this like so:
if(firstTimeOne == 0 && currentHighOne.getInt("levelOneHigh", 0) >= 20){ //First time getting a score over 20
                Toast.makeText(LevelSelect.this, "Unlocked level two!" +firstTimeOne, Toast.LENGTH_SHORT).show();
                firstTimeOne=1;
            }

The problem is, this code executes every time the user gets a score over 20... The firstTimeOne variable should be preventing that, right? It is set to 1 after this method has been called, preventing it to be called again. So, why is this method getting called more than once?
I make the variable firstTimeOne in my class, where I write:
int firstTimeOne = 0;

If you need my full code, here it is. It shows that I initialize the int in the class, rather than in a method:
https://gist.github.com/anonymous/b52a5873b9eb9324e671
EDIT:
Okay, so I am trying SharedPreferences, but get a null pointer exception on `edit.putInt("firstInt", 1); Here is the code: https://gist.github.com/anonymous/c5b71982559c245220df

   //ints will be zero if they do not have a value assigned to them...right?
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_level_select);

        levelTwoButton = (Button) findViewById(R.id.leveltwo);

        SharedPreferences currentHighOne = this.getSharedPreferences("levelOneScore", Context.MODE_PRIVATE);
        if (currentHighOne.getInt("levelOneHigh", 0) < 20) {
            levelTwoButton.setClickable(false);
            levelTwoButton.setText("Level two is locked!");
        }else{

            SharedPreferences firstTimeOne = this.getSharedPreferences("firstTimeOne", Context.MODE_PRIVATE); //Making a shared pref

            if(firstTimeOne.getInt("firstInt" , 5) == 5) { //Check if I've stored values in it yet
                edit = firstTimeOne.edit();
                edit.putInt("firstInt", 0); //Setting the default as 0
                edit.commit();
            }
            if(firstTimeOne.getInt("firstInt", 0) == 0 && currentHighOne.getInt("levelOneHigh", 0) >= 20){ //First time getting a score over 20
                Toast.makeText(LevelSelect.this, "Unlocked level two!" +firstTimeOne, Toast.LENGTH_SHORT).show();

                edit.putInt("firstInt", 1);
            }
        }
    }

Thanks so much for everything,

A:

Your int variable is a member of your Activity class and you're checking it in the activity's onCreate() callback which is only called when the activity is instantiated. Each instance of your activity is instantiated anew and member variables get their default values. It's not the same int you wrote that you are later reading.
If you want to persist data across activity instances, consider using e.g. SharedPreferences.

