title: Live data returning old values , onChanged is triggering multiple times
body: <p>I am using live data to update some view of the activity. the view contain question numbers both total question number and answered question number
   eg: 2/10 (answered/total)
  the questions can be filtered using actors, if no actor is selected then it will list all questions (consider the total questions number as 100) then if I am selecting any actor(like a developer, HR) then the questions total number is reduced to another value something less than 100 (like 20 ) 
  the total count is returned using the dao method</p>
  
  <pre><code> @Query("SELECT COUNT(actor) FROM questions WHERE actor IN (:actors)")
      LiveData&lt;Integer&gt; getNumberOfQuestions(String[] actors);
  </code></pre>
  
  <p>here String[] actors is the selected actor list</p>
  
  <p>Using an observer</p>
  
  <pre><code>questionsViewModel.getTotalQuestionCount(mCheckedActorList).observe(this, new Observer&lt;Integer&gt;() {
              @Override
              public void onChanged(@Nullable Integer countTotal) {
                  if (countTotal != null)
                      mTotalCount = String.valueOf(countTotal);
                  if (mAnswerCount != null &amp;&amp; mTotalCount != null)
                      mAllQuestionAnswered.setText(mAnswerCount.concat("/").concat(mTotalCount));
  
              }
          });
  </code></pre>
  
  <p>I am observing the count, but consider the scenario</p>
  
  <ol>
  <li>no filter applied (no actor selected,count =100)</li>
  <li>actor developer is selected (count = 20)</li>
  </ol>
  
  <p>onchanged in the first case returns 100 and in second it returns 100  and 20 
   I only want the current value, ie 20 how can solve this? what am I doing wrong?</p>
  
  <p><a href="https://i.stack.imgur.com/0wUvW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0wUvW.png" alt="enter image description here"></a></p>
  
  <p>in view model</p>
  
  <pre><code> public LiveData&lt;Integer&gt; getTotalQuestionCount(List&lt;String&gt; actorsList) {
          if (actorsList != null &amp;&amp; actorsList.size() &gt; 0) {
              String[] actorArray = new String[actorsList.size()];
              actorArray = actorsList.toArray(actorArray);
              return questionsRepository.getTotalCount(actorArray);
  
          } else {
              return questionsRepository.getTotalCount();
          }
      }
  </code></pre>