Tying things together

We have one more step! It's the practical use of our database classes and performing CRUD operations. We will extend the application to create notes, and we will focus on insertion.

Before we insert anything into the database, we must provide a mechanism to obtain the current user location since it's required for both notes and todos. Create a new class called LocationProvider and locate it in the location package as follows:

     object LocationProvider { 
       private val tag = "Location provider" 
       private val listeners =   CopyOnWriteArrayList <WeakReference<LocationListener>>() private val locationListener = object : LocationListener { ... } fun subscribe(subscriber: LocationListener): Boolean { val result = doSubscribe(subscriber) ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.