Thursday, June 2, 2011

column '_id' does not exist

In the exercise "A simple example using Android's SQLite database, exposes data from Cursor to a ListView", we have to add column "_id" in our database, and also include it in the queue. Why?

Because we use SimpleCursorAdapter to exposes data from a Cursor to a ListView widget. It's a subclass of android.widget.CursorAdapter. The Cursor must include a column named "_id" or this class will not work - refer to Android doc CursorAdapter.

So, we must:
- include column "_id" in database.
- include it in the queue.

Otherwise "java.lang.IllegalArgumentException: column '_id' does not exist" will be thrown!

2 comments:

souliyo said...

i need to see some example about the app working with RSS such as website or get information from the internet to show up on the screen.

Android Er said...

hello souliyo,

please refer Apply custom adapter to ListView for RSS Reader