该实体只包含一个项目ID,这也是primaryKey,我在DB中存储例如3个项目,当列表更新时,新的3个项目我需要用新的替换现有的列表。但对我来说它增加了新的,但我需要完全取代现有的如何用房间持久性中的新列表替换项目列表?
@Dao
public interface UserIdDao {
@Query("SELECT * FROM userIds")
Flowable<List<UserId>> allUserIds();
@Insert(onConflict = OnConflictStrategy.REPLACE)
List<Long> update(List<UserId> ids);
}
@Entity
public class UserId{
@PrimaryKey
private Long id;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserId userId = (UserFavoriteStore) o;
return (!id.equals(userId.id));
}
@Override
public int hashCode() {
int result = id.hashCode();
result = 31 * result + (id.hashCode());
return result;
}}
“时更新列表“ - 什么名单? – CommonsWare
列表更新(列表 ID); 我的意思是用户名列表 –