We Can Do Better

The next several tutorials will be focused on addressing these concerns, using solutions from the Jetpack components and from popular approaches in the Android development ecosystem.

Persistence: Room

In theory, we could save our to-do items to “the cloud”, persisting them on a server somewhere. However, that is complicated, in ways that go far beyond complicated Android code. It would require you to set up a server, or sign up for some service, to have something in the cloud for the app to talk to.

Besides, this is just a list of to-do items. Not everything needs a server.

So, we will keep the to-do items locally on the device. Specifically, we will use Room, the Jetpack solution for local databases. Room is a wrapper around Android’s built-in SQLite database. We can create classes that represent databases, tables, and operations (e.g., queries, inserts), and our ToDoRepository can use those to store the to-do items.

Asynchronous Work: Coroutines

There are a wide range of solutions for doing work asynchronously in Android. In these tutorials, we will use two, the first being Kotlin coroutines.

Coroutines are a recent addition to Kotlin that make it easy to designate some work to be done on background threads, while still making it easy to write code that consumes the results of that work on the main application thread.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.