I have a **SQLite database** which feeds data to the cardviews via an **ArrayList**. Every record in the database consists of a different color code, I want to set the background color of each individual card to its respective color present in the database. Color codes are under the "***color***" column inside the database.

Now here's my code, as you can see my **SQL SELECT Query** should only select ONE PARTICULAR RECORD for each individual card but what is doing here is that it selects **all the records** present in database.

If I use `c.moveToFirst();` it selects the first row of the table and if I use `c.moveToLast();` it selects the last row of the table? If I am clearing mentioning `...where id ="+cardid+";"`, isn't it supposed to select only one particular row?

The problem I am facing here is that it sets a common background color for all cardviews, I need it to be different for every card. What am I doing wrong?

*Code Reference :*

TextView **myid** consists of the unique identifier of every record in the database

```
  PersonViewHolder(View itemView, final Activity theact) {
            super(itemView);
            personName = (TextView)itemView.findViewById(R.id.person_name);
            personAge = (TextView)itemView.findViewById(R.id.person_age);
            personPhoto = (ImageView)itemView.findViewById(R.id.person_photo);
            myid = (TextView)itemView.findViewById(R.id.IDTAG);
            ohcolor = (TextView)itemView.findViewById(R.id.COLORCODE);

            cv = (CardView)itemView.findViewById(R.id.cv);
            cv.setUseCompatPadding(true);

            openDatabase();

            final String cardid = myid.getText().toString().trim();
            c = db.rawQuery("SELECT color FROM persons WHERE id ="+cardid+";", null);

            c.moveToFirst();
            colorbro = c.getString(0);
            i = Integer.parseInt(colorbro);
            cv.setCardBackgroundColor(i);

            cv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                     // do something
                }
            });
        }

```