CRUD operations

CRUD operations are operations for creating, updating, selecting, or removing data. They are defined with an interface called Crud and it will be generic. Create a new interface in the database package. Make sure it covers all CRUD operations:

 interface Crud<T> where T : DbModel { companion object { val BROADCAST_ACTION = "com.journaler.broadcast.crud" val BROADCAST_EXTRAS_KEY_CRUD_OPERATION_RESULT = "crud_result" } /** * Returns the ID of inserted item. */ fun insert(what: T): Long /** * Returns the list of inserted IDs. */ fun insert(what: Collection<T>): List<Long> /** * Returns the number of updated items. */ fun update(what: T): Int /** * Returns the number of updated items. */ fun update(what: Collection<T>): Int /** ...

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.