Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6914269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:19:32+00:00 2026-05-27T09:19:32+00:00

I have an application which has questions. After answer all the questions, score will

  • 0

I have an application which has questions. After answer all the questions, score will be saved. the problem is the application adds old score.

e.g :

first time take the exercise : i got 5 score
second time take the exercise : i got 10 score (i should get 5, but the application adds old score).
third time take the exercise : i got 14 score (i should get 4, but the application adds old score).

So, in this case, i have to quit the application first then run it again to get what i want, if not, so it keeps add the old score.

Is there anyone know about the problem? I use java which contains android library and sqlite.

public class QuestActivity extends Activity implements OnClickListener{

DatabaseUsername helper=null;
private Quest currentQ;
private SetGame currentGame;
private int userId;
public static final String LOG_TAG = "RIKA";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.questactivitylayout);
    currentGame = ((TheApplication)getApplication()).getCurrentGame();
    currentQ = currentGame.getNextQuestion();
    Button nextBtn = (Button) findViewById(R.id.nextBtn);
    final Button confirmBtn = (Button) findViewById(R.id.confirmBtn);
    setQuestions();

    helper=new DatabaseUsername(this);

    nextBtn.setOnClickListener(new View.OnClickListener() {
    String currentDateTimeString = DateFormat.getDateInstance().format(new Date());

        @Override
        public void onClick(View arg0) {

            /**
             * check if end of game
             */
            if (currentGame.isGameOver()){
                helper.insertMark(currentGame.getRight(), QuizAppActivity.number, currentDateTimeString );
                Log.e(LOG_TAG, "id value "+ userId);
                Intent i = new Intent(QuestActivity.this, TheEndActivity.class);
                startActivity(i);
                finish();
            }
            else{
                Intent i = new Intent(QuestActivity.this, QuestActivity.class);
                startActivity(i);
                finish();
            }
        }
    });

    confirmBtn.setOnClickListener(new View.OnClickListener() {
        private boolean clicked = false;

        @Override
        public void onClick(View arg0) {
            /**
             * validate a checkbox has been selected
             */

                if(!clicked){
                       clicked = true;      

                           // do your processing - one click only
                           if (!checkAnswer())                              
                                return;
                       }
                confirmBtn.setVisibility(View.INVISIBLE);
                confirmBtn.setVisibility(View.GONE);

               }


    });


}


private void setQuestions() {
    //set the question text from current question
    String question = ConvAddition.capitalise(currentQ.getQuestion()) + "?";
    TextView qText = (TextView) findViewById(R.id.question);
    qText.setText(question);

    //set the available options
    List<String> answers = currentQ.getQuestionOptions();
    TextView option1 = (TextView) findViewById(R.id.answer1);
    option1.setText(ConvAddition.capitalise(answers.get(0)));

    TextView option2 = (TextView) findViewById(R.id.answer2);
    option2.setText(ConvAddition.capitalise(answers.get(1)));

    TextView option3 = (TextView) findViewById(R.id.answer3);
    option3.setText(ConvAddition.capitalise(answers.get(2)));

    TextView option4 = (TextView) findViewById(R.id.answer4);
    option4.setText(ConvAddition.capitalise(answers.get(3)));
}


@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    switch (keyCode)
    {
    case KeyEvent.KEYCODE_BACK :
        return true;
    }

    return super.onKeyDown(keyCode, event);
}


private boolean checkAnswer() {

    TextView checkAnsText = (TextView) findViewById(R.id.checkAns);

    String answer = getSelectedAnswer();
    if (answer==null){
        return false;
    }
    else {
            if (currentQ.getAnswer().equalsIgnoreCase(answer))
        {
                currentGame.incrementRightAnswers();
                checkAnsText.setText ("Correct Answer " + answer);
                Log.e("Correct Answer", answer, null);

        }
        else{
                currentGame.incrementWrongAnswers();
                checkAnsText.setText ("Wrong Answer " + answer);
                 Log.e("Wrong Answer", answer, null);

        }
        return true;
    }
}


private String getSelectedAnswer() {
    RadioButton c1 = (RadioButton)findViewById(R.id.answer1);
    RadioButton c2 = (RadioButton)findViewById(R.id.answer2);
    RadioButton c3 = (RadioButton)findViewById(R.id.answer3);
    RadioButton c4 = (RadioButton)findViewById(R.id.answer4);
    if (c1.isChecked())
    {
        return c1.getText().toString();
    }
    if (c2.isChecked())
    {
        return c2.getText().toString();
    }
    if (c3.isChecked())
    {
        return c3.getText().toString();
    }
    if (c4.isChecked())
    {
        return c4.getText().toString();
    }

    return null;
}


@Override
public void onClick(View arg0) {
    // TODO Auto-generated method stub

}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:19:33+00:00Added an answer on May 27, 2026 at 9:19 am

    Check the initialization of your variables. It is likely that you just need to set the value to 0. It doesn’t have anything to do with Android I suppose

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which has to live as a service, I create an
I have an application which has a similar interface to Visual Studio, in that
I have an application which has a Projects table and a Users table. In
I have an AJAX application which has used CSS divs to create panels on
I have a Silverlight application which has on it a Canvas. On that Canvas,
I have an MVC application which has a set of fields for contact details
I have an iphone application which has about 4 tabs. How do I force
I have a Windows application which has a browser in it. The Windows application
I have a Java Application which has to load an DLL with a few
We have a Flex application which has several 'pages' worth of content. Each time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.