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 8889003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:09:19+00:00 2026-06-14T22:09:19+00:00

In my app ,one interface has some checkBoxes,I wish after I exit the interface,

  • 0

In my app ,one interface has some checkBoxes,I wish after I exit the interface, the CheckBoxes should maintain the state.So next time I enter it can show what I have done last time.I have used SharedPreferrences to achieve this.

checkbox1.setOnCheckedChangeListener(new OnCheckedChangeListener(){
    public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
// TODO Auto-generated method stub
Editor editor = getSharedPreferences("syllabus", 0).edit();
editor.putBoolean("cbx1_ischecked", isChecked);
editor.commit();
}
    });
checkbox2.setOnCheckedChangeListener(new OnCheckedChangeListener(){
    public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
    // TODO Auto-generated method stub
    Editor editor = getSharedPreferences("syllabus", 0).edit();
    editor.putBoolean("cbx2_ischecked", isChecked);
    editor.commit();
    }

});

But it doesn’t work. when I return to this page, All checkBox show state that “every item is unselected “.

How can I realize the function I wish?

  • 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-14T22:09:20+00:00Added an answer on June 14, 2026 at 10:09 pm

    After put date getSharedPreferences, You have to initialize your checkboz state with this data in onCreate, like below

    // onCreate

    SharedPreferences settings = getSharedPreferences("syllabus", 0);
    Boolean isChecked = settings.getBoolean("cbx1_ischecked", false);
    checkbox1.setChecked(isChecked );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little app that has been under development for some time. My
i create some project but when start App. How to Run this App one
I have an app that needs to wait for some unknown amount of time.
I'm writing a little command line todo app that has a general git-like interface.
This one has me stumped. I'm writing an iPhone app that tracks bus schedules.
I have the simplest PhoneGap app one could imagine! All I'm trying to do
I have two URLs: One is the application URL = http://domain.com/app One is the
When using the Scripting Bridge to access the Mail app one can easily retrieve
I created one app for database which contains a student table and 3 fields
I have one app, a UIImage* . I'm painting the image twice: Once in

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.