該實體只包含一個項目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); 我的意思是用戶名列表 –