I was reading this thread: What is the use of BaseColumns in Android, and I get how to use BaseColumns, that you have to fetch _id in your SELECT statements.
What’s still unclear to me is when is the _id field “internally” created? Is it during execSQL(…) that Android adds the _id field? Or, do we still have to define it in the CREATE TABLE statement?
You must create it “manually”. Android won’t do that for you.
For example, during table creation, you issue:
See? The
_idcolumn is explicitly named and added.Or, following the convention of DB-helper classes you’ll come up with something like that:
where the
TABLE_*andCOLUMN_*are constant fields of DB-helper, e.g.: