Android Room persistence library @Update not working : <p>I am trying to update my database via new android room library, but it is not working. Here it is my approach</p>

<pre><code>@IgnoreExtraProperties
@Entity(tableName = CarModel.TABLE_NAME,
    indices = {@Index(value = "car_name", unique = true)})
public class CarModel {

    public static final String TABLE_NAME = "cars";

    @PrimaryKey(autoGenerate = true)
    private int id;

    @ColumnInfo(name = "car_name")
    private String name;

    @ColumnInfo(name = "car_price")
    private String price;

    private String type;
    private String position;
}
</code></pre>

<p>MainActivity.java</p>

<pre><code>viewModel.isCarsEmpty().observe(MainActivity.this, new Observer&lt;Integer&gt;() {
                    @Override
                    public void onChanged(@Nullable Integer rowCount) {
                        if (rowCount == 0) {
                            viewModel.insertItems(list);
                        } else {
                            viewModel.updateItems(list);
                        }
                    }
                });
</code></pre>

<p>CarViewModel.java</p>

<pre><code>public LiveData&lt;Integer&gt; isCarsEmpty() {
    return appDatabase.carDao().isDbEmpty();
}
    public void insertItems(List&lt;CarModel&gt; carModels) {
    new insertCarsAsyncTask(appDatabase).execute(carModels);
}

private class insertCarsAsyncTask extends AsyncTask&lt;List&lt;CarModel&gt;, Void, Void&gt; {
    private AppDatabase db;

    public insertCarsAsyncTask(AppDatabase appDatabase) {
        db = appDatabase;
    }

    @Override
    protected Void doInBackground(List&lt;CarModel&gt;... params) {
        db.carDao().insertCars(params[0]);
        return null;
    }
}

public void updateItems(List&lt;CarModel&gt; list) {
    new updateCarsTask(appDatabase).execute(list);
}

private class updateCarsTask extends AsyncTask&lt;List&lt;CarModel&gt;, Void, Void&gt; {
    private AppDatabase db;

    public updateCarsTask(AppDatabase appDatabase) {
        db = appDatabase;
    }

    @Override
    protected Void doInBackground(List&lt;CarModel&gt;... params) {
        db.carDao().updateCars(params[0]);
        return null;
    }
}
</code></pre>

<p>CarDao.java</p>

<pre><code>@Insert(onConflict = REPLACE)
void insertCars(List&lt;CarModel&gt; cars);

@Update
void updateCars(List&lt;CarModel&gt; param);

@Query("SELECT count(*) FROM " + CarModel.TABLE_NAME)
LiveData&lt;Integer&gt; isDbEmpty();
</code></pre>

<p>I did debugging, new data comes and calling viewModel.updateItems(list) method.Thanks in advance!</p>
