title: How to build a string from items that are clicked?
body: <p>I'm trying to make a one String from views that are clicked and store them in database. I have created a list of different views and I want to save only the clicked ones.</p>
  
  <pre><code>final StringBuilder sb = new StringBuilder();
  final String prefix = " ";
  
  
      holder.cardView.setOnClickListener(new View.OnClickListener() {
          boolean isClicked = false;
  
  
          @Override
          public void onClick(View view) {
  
              if (isClicked) {
                  isClicked = false;
  
              } else {
                  String ingredient = holder.ingredientTextView.getText().toString();
                  sb.append(ingredient);
                  sb.append(prefix);
                  isClicked = true;
              }
          }
      });
      allIngredients = sb.toString();
  </code></pre>