title: Working on including Scores in Android Studio
body: <p>I'm trying to add scores in my game (i'm learning how to make games in Android), Now I have my button which checks if the answer is correct and another button which you click next to continue.</p>
  
  <p>I want players to be able to play the game such that once the answer is correct they get <code>1</code> score and if they get it wrong the score stays <code>0</code> ;My Button which checks if the answer is correct is where i want to set the scores (unless if i am doing it the wrong way) i dont want to display them on the same layout as the game but instead i have installed a timer and at finish i want the result to pop out(this i have an idea of how to do it). </p>
  
  <p>Now I have tried this and my game is not getting scores and once i ran the code it is okay but gives me the following </p>
  
  <p>d </p>
  
  <pre><code>by: java.lang.NumberFormatException: Invalid int: ""
              at java.lang.Integer.invalidInt(Integer.java:138)
              at java.lang.Integer.parseInt(Integer.java:358)
              at java.lang.Integer.parseInt(Integer.java:334)
              at java.lang.Integer.valueOf(Integer.java:525)
              at com.systematixnote.basicmathoperation.MathQuestion.getScore(MathQuestion.java:390)
              at com.systematixnote.basicmathoperation.MathQuestion.setHighScore(MathQuestion.java:274)
              at com.systematixnote.basicmathoperation.MathQuestion.onDestroy(MathQuestion.java:319)
              at android.app.Activity.performDestroy(Activity.java:6169)
              at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1141)
              at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3696)
              at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3727)
              at android.app.ActivityThread.access$1400(ActivityThread.java:151)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5257)
              at java.lang.reflect.Method.invoke(Native Method)
  </code></pre>
  
  <p>.. any help offered will be appreciated at this level.</p>
  
  <p>I bluntly have no idea on this one but any assistance will be appreciated</p>
  
  <p>Sample Code:
  My Button</p>
  
  <pre><code>   public void onClickCheck(View view){
          int answer;
      try{
          String ans = ((EditText)findViewById(R.id.answerField)).getText().toString();
  
  
          answer = Integer.valueOf(ans);
  
          if(answer == q.getAnswer()){
  
              correct = true;
              counter++;
  
  
  
          }else if(correct ==true){
              getScore();
  
          }else if(answer != q.getAnswer()){
              setHighScore();
  
  
              counter = 0;
          }
  </code></pre>
  
  <p>Get Score;</p>
  
  <pre><code>public int getScore() {
        int answer;
        String ans = ((EditText)findViewById(R.id.answerField)).getText().toString();
  
  
        answer = Integer.valueOf(ans);
          return Integer.parseInt(ans.substring(answer));
      }
  
  
  protected void onDestroy(){
          setHighScore();
          super.onDestroy();
      }
  </code></pre>