Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional Android 2 Application Development
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 17th, 2010, 04:07 AM
Authorized User
Points: 123, Level: 2
Points: 123, Level: 2 Points: 123, Level: 2 Points: 123, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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:

Code:
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:

Code:
private static final String DATABASE_CREATE =
  "create table " + EARTHQUAKE_TABLE + " ("
  + KEY_ID + " integer primary key autoincrement, "
  + KEY_DATE + " INTEGER, "
  + KEY_DETAILS + " TEXT, "
  + KEY_LOCATION_LAT + " FLOAT, " +
  + KEY_LOCATION_LNG + " FLOAT, " +
  + 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:

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


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 06: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 01:29 PM



All times are GMT -4. The time now is 02:16 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.