Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional Android 2 Application Development
BOOK: Professional Android 2 Application Development
This is the forum to discuss the Wrox book Professional Android 2 Application Development, 2nd Edition by Reto Meier; ISBN: 978-0-470-56552-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 2 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 17th, 2010, 04:07 AM
Authorized User
Join Date: Jun 2010
Posts: 18
Thanks: 0
Thanked 6 Times in 3 Posts
Default Problem: Chapter 7 "Creating and Using an Earthquake Content Provider" (Page 232)

Under the "Creating the Content Provider" subsection, in Step 3 there are a group of constants defined to represent the indices of the database columns in use. Two of these constants represent the latitude and longitude from the Location associated with a Quake:

public static final int LONGITUDE_COLUMN = 3;
public static final int LATITUDE_COLUMN = 4;
A few lines down from there the DATABASE_CREATE string is defined as:

private static final String DATABASE_CREATE =
  "create table " + EARTHQUAKE_TABLE + " ("
  + KEY_ID + " integer primary key autoincrement, "
  + KEY_MAGNITUDE + " FLOAT, " + // Removed previously documented ')' from this line
  + KEY_LINK + " TEXT);";
Looking at that constant, by my count latitude is the third column and longitude is the forth column. Therefore, the values of the LATITUDE_COLUMN and LONGITUDE_COLUMN constants are reversed. The code, as written, will store/retrieve the latitude to/from the longitude database column and the longitude to/from the latitude database column. The application may not exhibit incorrect behavior, but it is inconsistent with the column names.

To fix this, simply swap the values:

public static final int LONGITUDE_COLUMN = 4;
public static final int LATITUDE_COLUMN = 3;
The code on the web site also contains this problem.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem: Chapter 7 "Saving Your To-Do List" (Page 218) DrGaribaldi BOOK: Professional Android 2 Application Development 2 March 21st, 2011 01:53 AM
Big problem discovered at page 58 "Creating Simple Links" Antares BOOK: Beginning HTML, XHTML, CSS, and JavaScript 6 February 23rd, 2010 07:25 PM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
"Piblish to Provider..." Option Not Appearing in Database Explorer Context Menu chrisreyno BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 September 18th, 2009 11:05 AM
Earthquake Example problem "non-application token" Langley BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 2 January 28th, 2009 02:29 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.