android_catalogue1-6 Exercise 3: The Two Preserved Values ========================================================== 1. save() passing emptySet() as tagIds on an edit. saveItem (Chapter 3) deletes the item's existing tag links and then inserts exactly the ids it is given. With an empty set every link is deleted and none re-added. The item silently loses all its tags the moment the user edits ANY field, even just fixing a typo in the title. Where it shows: the detail screen's tags line disappears right after saving, and in Chapter 8 the item stops appearing in tag filters. Nothing errors, so it is easy to miss; the tag chip rows only reveal it. 2. save() passing System.currentTimeMillis() as createdAt. The item is rewritten with a new creation time on every edit, so the "Added" date becomes the date of the last edit. The list is ordered by createdAt DESC (Chapter 3), so an edited item jumps to the top of the list as if it were new. Where it shows: the list order changes after saving an edit, and the detail screen's "Added" field is wrong. The data is not lost, but the history is falsified. The shared lesson: an edit form only shows some of an entity's data. Anything not shown must be carried through unchanged, or the write quietly overwrites it. The same bug exists in web apps with partial forms.