Hello,
I am having a very hard time with updating my sqlite database. I
added 2 new columns to my database: latitude and longitude. When I
generated my cursor, it returned:
java.lang.IllegalArgumentException: Invalid column latitude
I am using the android emulator on Ubuntu Linux Jaunty. I tried to
issue command emulator with -wipe-data directive, but it didn't help.
I also cleaned the eclipse project. It didn't help either.
I tried to query sqlite, and the column in question, latitude is there
and has a value:
sqlite> .schema jobs
CREATE TABLE jobs (_id INTEGER PRIMARY KEY,jobId INTEGER,name
TEXT,report TEXT,address TEXT,assigned INTEGER,city TEXT,country
TEXT,description TEXT,dueDate INTEGER,end INTEGER,owner INTEGER,phone
TEXT,priority TEXT,start TEXT,status TEXT,zip TEXT,latitude
NUMERIC,longitude NUMERIC,created INTEGER,modified INTEGER);
select * from jobs
...> ;
1|1|Veggie Delivery|asdfasdf|5151 Main Street|1256332583140|
Weatherford|USA|
Vegetable Delivery Run to local Farmers Market|1256332583140|
1256337902372|1|
|Normal|1256337892025|Completed|76087|
(this is the latitute) 32.6679938434882|-97.7885007051725|
1256396137205|1256396137205
This is my code:
private static final String[] PROJECTION = new String[] {
Jobs._ID, // 0
Jobs.NAME, // 1
Jobs.JOB_ID, // 2
Jobs.ADDRESS, // 3
Jobs.CITY, // 4
Jobs.COUNTRY, // 5
Jobs.PHONE, // 6
Jobs.ZIP, // 7
Jobs.LATITUDE, // 8 This generates the exception. It
works fine
with this commented out.
Jobs.LONGITUDE // 9
};
/** The index of the title column */
private static final int COLUMN_INDEX_NAME = 1;
private static final int COLUMN_INDEX_JOB_ID = 2;
private static final int COLUMN_INDEX_ADDRESS = 3;
private static final int COLUMN_INDEX_CITY = 4;
private static final int COLUMN_INDEX_ZIP = 7;
private static final int COLUMN_INDEX_COUNTRY = 5;
private static final int COLUMN_INDEX_PHONE = 6;
private static final int COLUMN_INDEX_LATITUDE = 8;
private static final int COLUMN_INDEX_LONGITUDE = 9;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.job_map);
final Intent intent = getIntent();
mUri = intent.getData();
mCursor = managedQuery(mUri, PROJECTION, null, null, null);
startManagingCursor(mCursor);
// I don't think the cursor ever got here.
if (mCursor != null) {
mCursor.moveToFirst();
Log.d(TAG, Integer.toString(mCursor.getColumnIndex
(Jobs.LATITUDE)));
latitude = mCursor.getDouble(COLUMN_INDEX_LATITUDE);
longitude = mCursor.getDouble(COLUMN_INDEX_LONGITUDE);
}
This is the error that I received:
E/AndroidRuntime( 842): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 842): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.lc.otopulse.android.jobs/
com.lc.otopulse.android.jobs.JobMap}:
java.lang.IllegalArgumentException: Invalid column
latitude
E/AndroidRuntime( 842): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2401)
E/AndroidRuntime( 842): at
android.app.ActivityThread.startActivityNow(ActivityThread.java:2242)
Any hints or directions that you can give me on this would be much
appreciated. Thank you for your kind assistance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---