Here is my code for a simple cursor adapter.
public class CursorList extends ListActivity {
/** Called when the activity is first created. */
@Override
public vo
You need to include the table _id in the projection. the list cursor adapter needs the _id to keep track of the rows. you don't have to actually display it anywhere or use it but the cursor needs to contain that column. also a primary key column named _id is mandatory in every android table.
Why does it give an error that column '_id' doesn't exist? Is it a necessary column which we have to have in our tables?
Yes, if you want to use your database information in a cursor adapter. The adapter uses it for internal purposes. Your table must have an '_id' column, and you must select it in your query (so it is in the Cursor
result set). You do not have to actually display it in your ListView
.
Revised for Posterity
Instead of actually adding the '_id' column, you can SELECT
your own 'id' column as '_id', and it will work just the same.
Write Cursor related code in try catch block.Your problem will be solved.Check when created table you typed different column rather than '_id'