title: I have a problem with Livedata observer called multiple time
body: <p>This is my CartProductItemDao.</p>
  
  <pre><code>    @Dao
  public interface CartProductItemDao {
  
      @Query("select * from CartProductItem where product__category__id = :id")
      LiveData&lt;List&lt;CartProductItem&gt;&gt; getCartProductItemList(int id);
  
      @Query("select * from CartProductItem where product__id in (:items)")
      LiveData&lt;List&lt;CartProductItem&gt;&gt; getAllProductsSectionItem(ArrayList&lt;Integer&gt; items);
  
      @Query("Select * from CartProductItem  where product__fav_market_id =:id")
      LiveData&lt;List&lt;CartProductItem&gt;&gt; geAllCartProductItemList(int id);
  }
  </code></pre>
  
  <p>and this is my CartProductItemRepository.</p>
  
  <pre><code>    public class CartProductItemRepository {
      LiveData&lt;List&lt;CartProductItem&gt;&gt; cartProductItemList;
      CartProductItemDao cartProductItemDao;
  
      public CartProductItemRepository(Application application) {
          TreaderOnlineDatabase treaderOnlineDatabase=TreaderOnlineDatabase.getInstance(application);
          cartProductItemDao=treaderOnlineDatabase.cartProductItemDao();
      }
  
      public LiveData&lt;List&lt;CartProductItem&gt;&gt; getCartProductItemList(int cat_id) {
          cartProductItemList= cartProductItemDao.getCartProductItemList(cat_id);
          return cartProductItemList;
      }
  }
  </code></pre>
  
  <p>and this is my CartProductItemViewModel.</p>
  
  <pre><code>    public class CartProductItemViewModel extends AndroidViewModel {
      LiveData&lt;List&lt;CartProductItem&gt;&gt; cartProductItemList;
      LiveData&lt;List&lt;CartProductItem&gt;&gt; productSectionItemList;
      LiveData&lt;List&lt;CartProductItem&gt;&gt; allCartProductItem;
      CartProductItemRepository cartProductItemRepository;
  
      SharedPreferenceClass sharedPreferenceClass;
  
      public CartProductItemViewModel(@NonNull Application application) {
          super(application);
          cartProductItemRepository=new CartProductItemRepository(application);
          sharedPreferenceClass=new SharedPreferenceClass(getApplication());
          //cartProductItemList=cartProductItemRepository.getCartProductItemList();
      }
  
      public LiveData&lt;List&lt;CartProductItem&gt;&gt; getCartProductItemList(int id) {
          cartProductItemList=cartProductItemRepository.getCartProductItemList(id);
          return cartProductItemList;
      }
  }
  </code></pre>
  
  <p>and I called getCartProductItemList(cat_is) from inside fragment
  and this is the code </p>
  
  <pre><code>    @Override
  public void recyclerViewOnClick2() {
      CartProductItemViewModel cartProductItemViewModel;
      cartProductItemViewModel=ViewModelProviders.of(this).get(CartProductItemViewModel.class);
      int x=sharedPreferenceClass.getSharedPreferenceCatId();
      cartProductItemViewModel.getCartProductItemList(x).observe(this, new Observer&lt;List&lt;CartProductItem&gt;&gt;() {
          @Override
          public void onChanged(List&lt;CartProductItem&gt; cartProductItems) {
              product_categoriesFragmentAdpter.setArrayList(cartProductItems, getContext());
          }
      });
  }
  </code></pre>
  
  <p>the problem when I make an update or delete for table or insert this observer called multiple times.</p>