Handling “column ‘_id’ does not exist” Error When Using CursorAdaptor

1. Check whether the primary key in your table is called “_id”.  Android’s CursorAdaptor will always try to look for “_id” column even when the primary key name is explicitly changed/defined in create table statement listed in the sqllite3 manual (http://www.sqlite.org/lang_createtable.html see row ids and primary key). The easiest way to get rid of this error is to rename your primary key to _id. Otherwise you will have to code a custom adaptor.

2. You will have to include the _id column when retrieving the cursor. ie :

Cursor cursor = database.query(Frequency.TABLE_FREQUENCY,
				new String[] {"Description","_id"}, null, null, null, null, null);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: