title: Favorite switch button in RecyclerView
body: <p>You might have seen in most of the apps, they use Add as favorite, and they will display user's favorite data to another Activity. I am trying to do but I am unable to do. I know for saving the value I must use Context.Mode_append in shared Preferences, but which value?</p>
  
  <p>Do I send position of recyclerView list items or I need to send string? I have found similar question in Stack Overflow but none of these are helpful because they aren't on detail. Below is the screenshot and I am also trying that if the start button is press then color this in yellow, below is the code I tried but it only changes when I hold the button.</p>
  
  <p>start.xml from drawable</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;item android:drawable="@android:drawable/btn_star_big_on" android:state_pressed="true" /&gt;
  
  &lt;item android:drawable="@android:drawable/star_on" android:state_selected="true" /&gt;
  &lt;item android:drawable="@android:drawable/star_big_off" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>I called button in cardView where CardView is my parent layout</p>
  
  <pre><code>&lt;ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:src="@drawable/star"
          android:background="@android:color/transparent"/&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/MQF6A.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MQF6A.jpg" alt="enter image description here"></a></p>