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

  • SEARCH
  • Home
  • 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 7828649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:25:34+00:00 2026-06-02T10:25:34+00:00

I have created an activity that refresh quotes when the user clicks a button.

  • 0

I have created an activity that refresh quotes when the user clicks a button. Within the same activity there is a check box which the users can click if they like the quote.

Everything works perfectly apart from the check box. When the user clicks they like the quote, I want that check box checked. This only happens when the user moves away from the activity and returns at a later stage.

However when the user stays within the activity and returns to the quote, the old state is shown instead of the users preference.

The check box is configured from the values even in the database, if the value is 1, the check box should be ticked, if not, check box should be clear.

The code is shown below:

When the user clicks the next button, the following code is executed:

Button nextGenerateButton = (Button) findViewById(R.id.btn_next_quotes);
nextGenerateButton.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
        // TODO Auto-generated method stub
        String nextQuote = myDbHelper.getnextQuote();
        setQuoteDisplay(nextQuote);
        btn_favorite.setChecked(myDbHelper.getFavouriteCheckBoxValue());

    }
});

The button retrieves the next quote and the getFavouriteCheckBoxValue() confirms whether the favourite column is marked in the database and either returns a true of false which sets the check box value.

public boolean getFavouriteCheckBoxValue()
    {
        int laballedFavourite = cursor.getInt(0);

        if(laballedFavourite == 0)
        {
            return false;
        }
        else
        {
            return true;
        }
    }

if the user likes the quote, the code executes the addFavourite() which updates the table where the favourite column will be modified on one.

btn_favorite.setOnCheckedChangeListener(new OnCheckedChangeListener() {

    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        // TODO Auto-generated method stub              
        if(isChecked == true)
        {
            myDbHelper.addFavourite();
        }

        if(isChecked == false)
        {
            myDbHelper.removeFavourite();
        }
    }
});


public void addFavourite()
{
    ContentValues vals = new ContentValues();
    vals.put("favouriteQuote", 1);
    db.update(TABLE_NAME, vals, "columnId = " + cursor.getInt(1), null);
}

Again this only works perfectly when I resume the quote activity and not when I am currently live in the quote activity.

Hope this makes sense.

Any help would be greatly appreciated.

  • 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-06-02T10:25:36+00:00Added an answer on June 2, 2026 at 10:25 am

    Refreshing cursor solved the problem.

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

Sidebar

Related Questions

I have created a custom workflow activity that copies attachments from a case to
I have created an activity which sends a number of notifications to status bar.
I have created an Activity (CodeActivity) that retrieves the temperature where I live. I
I have created an Activity with a AutuCompleteTextView[ACTV] and button. I enter some text
I have created a custom workflow activity in CRM that creates a task. The
I have an activity that starts a long-running service which in turn adds an
I have created an Activity that shows a listview and on swipe action another
I have created a custom activity that I am using in my workflows. Initially
I have created an activity in which I have created a progress bar as
i am having a very simple problem. I have created an activity in which

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.