The DAO interface GenderDao.kt belonging to Gender.kt contains the usual database methods insert, update, delte and get. It also contains the method getAllGenders, which returns all entries whose ID is greater than the passed parameter id and whose inactive value is ¡= the parameter inactiveValue, sorted alphabetically. The addition ’COLLATE LOCALIZED’ ensures that, for example, German umlauts are sorted correctly. The parameter id in the method getAllGenders has the following purpose: For tables whose values are displayed in a drop-down list (such as gender), an empty value (with the string value ’—’) is created as the first entry with ID=1 when the database is created. If the app needs this empty value, the id parameter with the value 0 is passed to the getAllGenders method. If the app does not need this empty value (e.g. in the RecyclerView list in which all editable entries are displayed), the id parameter with the value 1 is passed to the getAllGenders method. The parameter inactiveValue specifies whether inactive entries are to be returned (value=1) or not (value=0). If this parameter is not specified when the method is called, 0 is used as the default value (inactive entries are therefore not returned).
The DAO interface PersonDao.kt belonging to Person.kt contains the usual database methods. Analogous to GenderDao.kt, there is a method getAllPersons, which returns persons contained in the database depending on the parameters passed. Furthermore, the method getAllGenders is defined in this DAO class, which is used to determine the genders for the corresponding drop-down list in the user interface.
The DAO interface TagDao.kt belonging to Tag.kt contains the usual database methods and the method getAllTags, which should be understandable based on the previous descriptions.
The DAO interface PreferencesDao.kt belonging to Preferences.kt contains the usual database methods and the methods getMainUser, which determines the main user, as well as the methods getPreferences() and getAllPersons(), which should be understandable due to the previous descriptions.
The DAO interface DiaryEntryDao.kt belonging to DiaryEntry.kt contains the usual database methods for insert, update and delete. The read methods getDiaryEntryWithEverything() and getDiaryEntriesWithEverything(), on the other hand, use our extended class DiaryEntryWithEverything.kt, so that we also have access to the assigned person and the assigned keywords. Since several database tables are accessed here in one SQL statement (diary_entries, diary_entries_tags, tags), the statements must be marked with the annotation @Transaction. The method inserDiaryEntryTag() is responsible for inserting entries in the table diary_entries_tags, the method deleteAllTagsForEntry() deletes all keywords of a concrete diary entry (with the ID passed as parameter) from the table diary_entries_tags.