Simple Cursor Adapter problem

后端 未结 3 1966
北荒
北荒 2021-01-25 08:01

Here is my code for a simple cursor adapter.

public class CursorList extends ListActivity {
/** Called when the activity is first created. */
@Override
public vo         


        
3条回答
  •  余生分开走
    2021-01-25 08:26

    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.

提交回复
热议问题