column '_id' does not exist - Blog Android

Thursday, 2 June 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!

Borneo08

About Borneo08

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :

More links

Related Posts Plugin for WordPress, Blogger...