Reputation: 1320
I query my database as below:
@Query("SELECT * FROM employees")
public LiveData<List<Employee>> getAllEmployees();
and with one MediatorLiveData I observe on result like this:
data.addSource(DAO.getAllEmployees(), employeeList -> {
if (employeeList==null) return;
data.setValue(employeeList);
});
Every time that data is inserted into employees table, this observer is called, but the problem is employeeList only has one item while db has more than one item.
Upvotes: 0
Views: 377
Reputation: 1320
It was my fault, I've done a mistake in parsers and the DB data was replaced because of onConflict = OnConflictStrategy.REPLACE
.
Upvotes: 1