这个场景真的很不一样,我想实现,但我不知道如何去做。我的场景是这样的:
我有一个ArrayList,这ArrayList总是用新的更新。请这样想。
列表一是我的目标列表。我在这个列表中有这些项目:
乙丙
我在首次发布时两次保存此列表:list_old_one - list_new_one
几分钟后,新物品与旧物品一起出现。
A B C D
而且我正在保存这个列表: list_new_one
我想做这个。如果C不存在 to list_one_now,我只想显示这个,我想删除所有其他项目,只显示C而不是D
我厌倦了equal和removeAll部分但也即将到来的项目D因为它不相等。
我的数组列表:
TinyDB tinydb = new TinyDB(getApplicationContext());
//Adding current list to new one
tinydb.remove("list_new_one");
tinydb.putListString("list_new_one", all_list);
ArrayList<String> list_old = new ArrayList<>(tinydb.getListString("list_old_one"));
ArrayList<String> list_new = new ArrayList<>(tinydb.getListString("list_new_one"));
list_old.removeAll(list_new);
if (list_new.size() != 0) {
//Adding results to database
DBRecentlyHelper dbRecentlyHelper = new DBRecentlyHelper(getApplicationContext());
dbRecentlyHelper.RecentlyADD(list_old, current_user);
dbRecentlyHelper.close();
//Updating old list
tinydb.remove("list_old_one");
tinydb.putListString("list_old_one", all_list);
}else{
//Updating old list
tinydb.remove("list_old_one");
tinydb.putListString("list_old_one", all_list);
}
我真的在找一个星期,但仍然得到错误的结果。
如果有人有想法,我会很高兴。非常感谢。
海绵宝宝撒
忽然笑
LEATH
相关分类