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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:40:12+00:00 2026-05-26T16:40:12+00:00

I am using a custom List adapter to display a list of all contacts,

  • 0

I am using a custom List adapter to display a list of all contacts, and the user will then select contacts by clicking a checkbox. What is a good method of saving the selected contacts to preferences, so that I may test against them elsewhere? I was thinking of using SharedPreferences, but so far I have been unable to find a way to save an array to SharedPrefs. I could go the sqlite route, but that seems a bit excessive considering they are already contained in a db, and why couldn’t I just reference them there. Just not sure how to even begin to do that…
Also, I was thinking of calling this method onDestroy, though that could have some issues as well, so a recommendation on that could help as well. Here is some code (let me know if you need more,,,there’s always more)
thanks for your supreme knowledge.

ListItemLayout.xml:

<?xml version="1.0" encoding="utf-8"?>
<TwoLineListItem 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:id="@+id/relativelayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <TextView
            android:id="@android:id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp"
            android:textStyle="bold" />

        <TextView
            android:id="@android:id/text2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/text1"
            android:includeFontPadding="false"
            android:paddingBottom="4dip"
            android:textSize="15sp"
            android:textStyle="normal" />

         <CheckBox
                android:id="@+id/checkbox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:focusable="false"
                                 />
 </RelativeLayout>
</TwoLineListItem>

ContactPicker Activity (some code redacted for brevity’s sake):

public class ContactPicker extends ListActivity implements Runnable{


        private List<Contact> contacts = null;
        private Contact con;
        private ContactArrayAdapter cAdapter;
        private ProgressDialog prog = null;
        private Context thisContext = this;
        private CheckBox c1;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            prog = ProgressDialog.show(this, "Contact List", "Getting Contacts", true, false);
            Thread thread = new Thread(this);
            thread.start();

            final CheckBox c1 = (CheckBox)findViewById(R.id.checkbox);

        }
public void run() {...
}
private List<Contact> fillContactsList() {...
}
 private Handler handler = new Handler() {...
}
@Override
        protected void onListItemClick(ListView l, View v, int position, long id) {
            super.onListItemClick(l, v, position, id);
            TextView label = ((TwoLineListItem) v).getText2();
            String phoneNumber = label.getText().toString();
}
}
  • 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-26T16:40:13+00:00Added an answer on May 26, 2026 at 4:40 pm

    If all you need is to store a list of objects (users) I would skip the DB and just create a JSON object and store that as a String in a shared preference. It obviously depends on how many users you expect to store, but if it’s a few hundred or less, you’re not going to see any sort of performance loss, and you can avoid dealing with all the db setup.

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

Sidebar

Related Questions

I am currently ordering a list of custom objects using the IQueryable OrderBy method
I have created a custom listview using adapter. Each row of the list view
I'm making a custom adapter so that I can display a list of items
I have implemented an application with Custom base adapter for display data in list
I am getting XML data from url and displaying using a custom list adapter
I am using a ListActivity to display an iconified list (using a custom implementation
I have List of items. I'm using custom adapter (Android 1.5). Everything works perfectly,
I'm using a custom list adapter for my ListView. How can I get the
I need a little help with my custom list view adapter. I'm using the
i am sending array list items[x,y,z...] to the custom adapter. i want display items

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.