1

I have many checkboxes in my activity. What i want to do is when i click on any one of the checkbox then the relevant search should be made in the database and the value should be retrived considering the value of the checkbox.

for eg. if i have checked the first checkbox only then

if(chk1.ischecked){
      str="yes";
}

so my query will be

select * from database where abc="yes";

But what if i have checked 2 or more checkboxes the query changes.

select * from database where abc="yes" and pqr="yes";

There can be many permutation and combinations for these 10 checkboxes. What can be the easiest way by which i can make my search work.

enter image description here

Droid
  • 419
  • 4
  • 15
  • Are these checkboxes going to change over time or are they fairly fixed? – ryan1234 Apr 18 '13 at 17:33
  • I would consider using a bit mask to store the values. It makes queries very fast and easy. Here is an article to give you the concept: http://stackoverflow.com/questions/1987738/create-a-permission-bit-mask-in-java. Instead of permissions you're storing which checkbox is on and which is off. Then you can just store an integer and then examine the bits to see what's on and what's off. It also makes querying things that are similar very easy. – ryan1234 Apr 19 '13 at 16:40

0 Answers0