title: Get and Store text from looped checkboxes into a String
body: <p>I am kinda new in android and java programming, and I have a question, wish you could help me to solve it :)</p>
  
  <p>I have a Program, it will fetch and loop data from database and convert it into some checkboxes, then user must check the checkboxes and hit the submit button,,
  The value(s) of the checked checkboxes will be stored to a String[], then will be send to another activity via Intent.putExtra..</p>
  
  <p>So far, all I can do is fetch and loop the data from database, but I have no idea about how to store all the checked value (of the checkboxes) to string and sent it to another activity via intent. Can you guys please help me with this and where should I put the code?</p>
  
  <p>And here is my code :</p>
  
  <pre><code>private void fetchFromDatabase() {
      // TODO Auto-generated method stub
      myDb.open();
      int totalGroup = myDb.countHowManyGroups(Username);
      String groupId[] = myDb.fetchGroupId(Username);
      String groupName[] = myDb.fetchGroupName(Username);
      String flag[] = null;
      for (int i = 0; i &lt; totalGroup; i++) {
  
          listCheckBox = new CheckBox(this);
          listCheckBox.setText(groupName[i]);
          listCheckBox.setTag(groupId[i]);
  
          if (listCheckBox.isChecked()) {
              int x=0;
              flag[x]=listCheckBox.getText().toString();
              x++;
          }
  
  
          layout.addView(listCheckBox);
      }
      myDb.close();
  
      Button bSubmit = new Button(this);
      bSubmit.setText("Submit");
      layout.addView(bSubmit);
  
      bSubmit.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              if (listCheckBox.isChecked()) {
  
              }
  
          }
      });
  }
  </code></pre>