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.