O'Reilly logo

Mastering Android Development with Kotlin by Miloš Vasić

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required