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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:11:32+00:00 2026-05-23T10:11:32+00:00

I am developing an application that enables management of tasks in which I have

  • 0

I am developing an application that enables management of tasks in which I have two activities. The first activity is a simple listview, which is presented a list of users. The second activity is a multiple choice listview, which shows the tasks associated with that user. I managed to reach my first goal which was to store the state of the checkbox, using shared preferences. My problem is that when I save the state of checkboxs for a user, when you see the tasks of another user, these are no longer checked.
How can i solve my problem.

This is how I fill the list:

    mList = (ListView) findViewById(android.R.id.list);      
    final DbAdapter db = new DbAdapter(this);
    db.open();  
    data = db.getAllTasks(getIntent().getExtras().get("nameUser").toString());
    adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice,data);
    mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    mList.setAdapter(adapter);

This is the way i select the user i want to show the tasks:

        mList.setOnItemClickListener(new OnItemClickListener() {     
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {
            final String text = (String) mList.getItemAtPosition(position);
        }
    });

And this is the methods i use to save the state using SharedPreferences:

    private void LoadSelections() {
    // if the selections were previously saved load them

    SharedPreferences settingsActivity = getPreferences(MODE_PRIVATE);

    if (settingsActivity.contains(SETTING_DB)) {
        String savedItems = settingsActivity
                .getString(SETTING_DB, "");

        this.selectedItems.addAll(Arrays.asList(savedItems.split(",")));
        int count = this.mList.getAdapter().getCount();

        for (int i = 0; i < count; i++) {
            String currentItem = (String) this.mList.getAdapter()
                    .getItem(i);
            if (this.selectedItems.contains(currentItem)) {
                this.mList.setItemChecked(i, true);
            }

        }

    }
}


private void SaveSelections() {

    // save the selections in the shared preference in private mode for the user

    SharedPreferences settingsActivity = getPreferences(MODE_PRIVATE);
    SharedPreferences.Editor prefEditor = settingsActivity.edit();

    String savedItems = getSavedItems();

    prefEditor.putString(SETTING_DB , savedItems);

    prefEditor.commit();
}



private String getSavedItems() {
    String savedItems = "";

    int count = this.mList.getAdapter().getCount();

    for (int i = 0; i < count; i++) {

        if (this.mList.isItemChecked(i)) {
            if (savedItems.length() > 0) {
                savedItems += "," + this.mList.getItemAtPosition(i);
            } else {
                savedItems += this.mList.getItemAtPosition(i);
            }
        }

    }
    return savedItems;
}

My regards.

  • 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-23T10:11:32+00:00Added an answer on May 23, 2026 at 10:11 am

    You’ll need to include, as part of your Preferences, the user those particular tasks are assoicated with. It’s not ideal to use the SharredPreferrences for this purpose (better to simply use the database instead IMO), but in the end you need to find the selected items to a particular user, then when the user is selected you can see “which” items where selected.

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

Sidebar

Related Questions

I'm developing a remote desktop application that enables users to connect remotely to a
I have an application which I am developing using WPF\Prism\MVVM. All is going well
I am developing a WPF application, and have a TextBlock which I want to
I am developing sample application that uses Google Map API. I have generated Google
I am developing some application at the moment which can run in two environments
I have an Asp.Net MVC Web Application that I am developing. I have TeamCity
I have an application on C#/WPF that I`m developing ... I have a btn
So I'm developing my first iOS application and I need help.. Simple program for
I'm developing application that can be useful only in my country(Ukraine). In Ukraine people
When developing an application that sends out notification email messages, what are the best

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.