Using the Database in Your Application
You have created the coordinate model, but now you need to test whether the database tables are being correctly created. It’s not easy to test the full application in the emulator, but you can make a few minor modifications to the existing code to test this code to ensure it is working. Follow these steps.
1. Open the WhereAmI.java
class in the com.androiddevbook.onyourbike.chapter7.helpers
package. If the map has not been created in the MapActivity
class, then map
will be null
. Inside the onLocationChanged
method, find any code that refers to the map’s methods, and protect them with an if
. Be sure to check that map
is not null
(see Listing 7.49).
Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications 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.