I am implementing a database in my Android application and it has caught my attention that all the tutorials I have seen always call the id of the tables _id
or that they call an interface called BaseColumns that provides the name in string _id
.
I am not using the name _id
for all the ids of the tables in my database. An example of an id of my database idPedidos
would be because my table is called Pedidos
, plus most are AUTO_INCREMENT
.
My question is am I really working in vain by not putting the name _id
to the id of my tables and if so why is this happening if it's just a string name?
Thanks in advance.
SQLite , if it supports auto-incremental ids that are not called “_id”, I'll tell you that in some projects I also have a column defined as AUTOINCREMENT that is not _id and sometimes I use it as a reference.
The main reason for having the _id field is that in some projects we regularly use cursors to access data in a Sqlite DB , it seems to me that you were asking about a Custom CursorAdapter, therefore the importance of the _id column is:
if you don't have the _id column defined, you would get the message:
If you are going to create a Cursor to access the data you should use
_id