直接说重点:
1.不能直接用for循环+remove的方式,会报错。
2.推荐使用 Iterator+remove的方式
Iterator<EntityNote> noteIterator = notes.iterator();
while (noteIterator.hasNext()) {
EntityNote note = noteIterator.next();
if (note.getCall_() == -1) {
noteDao.deleteByKey(note.getId_());
List<EntityNoteFile> _files_list_remove = noteFileDao.queryBuilder().where(EntityNoteFileDao.Properties.Note_id_.eq(note.getId_())).list();
noteFileDao.deleteInTx(_files_list_remove);
noteIterator.remove();
} else {
files.addAll(note.getFiles_());
note.setAnchor_(note.getModified_());
note.setSync_(AppConfig.DataStatusSynch.LOCAL_REMOTE_SYNC.getValue());
}
}
noteDao.insertOrReplaceInTx(notes);
3.工作实在太忙,每次都只能写一点点。