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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:19:14+00:00 2026-05-16T21:19:14+00:00

I have some 34 checkboxes on one Activity which i have to mark and

  • 0

I have some 34 checkboxes on one Activity which i have to mark and unmark. and I want to save the status of the each checkbox.

I want this persistently. So should i have a sqlite table or preferences ?

If sqlite table is recommended, then what should be the ideal table structure design?

  • 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-16T21:19:14+00:00Added an answer on May 16, 2026 at 9:19 pm

    You could do it either by using SQLite or preferences. Though… what you want to do is kind of simple, so why would you care of creating a table, creating SQliteOpenHelper objects, designing a table, etc. The preferences approach is simpler.

    So… what is most important here is how you identify your checkboxes. If you have just 34 static checkboxes (meaning they won’t change its order) and they are into an array (which would be ideal), you have it easy.

    As you might know, preferences editor does not allow to save arrays. So you have some choices:

    • Saving each state into a different preference slot (for instance: putBoolean("checkbox2", true); putBoolean("checkbox3", false); ect.)
    • Save all states into an String: putString("checkboxes_state", "10101011100011010"); this way you will have a String with 34 chars, each char represents a state.
    • If you want efficiency, you can represent all states with a simple long equals or lower than 17179869183. For instance putLong("checkboxes_state", 17179869183) would mean that all checkboxes are selected (because its binary representation is 1111111111111111111111111111111111). More examples:
      • 12159999103 = 1011010100110010101101110001111111
      • 1 = 0000000000000000000000000000000001, meaning that only the last checkbox is selected.

    Edit

    With regards to your question of why the last one is more efficient let me briefly explain. The first one implies using 34 preferences slots (actually I don’t know how they are stored; hopefully, android team took care of performance). The second approach will use a 34 chars String; so, the minimum size that the String object would have is:

    minimum String memory usage (bytes) = 8 * (int) ((34 * 2 + 45) / 8) = 113 bytes
    

    Meaning that a String of that lengthen will take up at least 113 bytes. On the other hand, using just one long will take up 8 bytes only. The less bytes to work with, the faster your app will be (because Android will have to process and save less bytes).

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

Sidebar

Related Questions

I have some checkboxes in vb.net code. <tr> <td colspan=2> <asp:CheckBox ID=chkbxCreateAmendOrg runat=server Checked=False
I have an ASP.Net user control that contains some checkboxes, and I want to
I have some ASP.NET web services which all share a common helper class they
I have some classes layed out like this class A { public virtual void
I have some C# / asp.net code I inherited which has a textbox which
I have some code like this in a winforms app I was writing to
I have some kind of test data and want to create a unit test
Have a form that is emailed with checkboxes. Some checkboxes have an optional field
I have a GridControl view which is being populated with one column as a
I have some UI in VB 2005 that looks great in XP Style, but

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.