Does Android SQLite not support incremental auto ids that are not called "_id"?

3

I'm doing an implementation of a database in my Android application and I've noticed that all the tutorials I've seen, always call the id of tables _id or call an interface called BaseColumns that gives the name in string _id .

I am not using the name _id for all the id of the tables in my database. An example of an id of my BD would be idPedidos because my table is called Pedidos , plus most are AUTO_INCREMENT .

My question is if I'm really working in vain not to put the name _id to the id of my tables and if so, why does this happen if it's just a string name?

Thanks in advance.

    
asked by Vicky Vicent 05.06.2016 в 13:38
source

1 answer

2

SQLite , if you support auto-incremental ids that are not called "_id", I mention 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 the data in a BD Sqlite , I think you asked about a Custom CursorAdapter, therefore the importance of the _id column is:

  

CursorAdapter : The cursor must include a column named "_id" or this class must not   it will work. Also, using MergeCursor with this class will not work   if the merged cursors have overlapping values in their   "_id" columns.

If you have not defined the _id column, you would get the message:

  

The Cursor must include a column named _id or this class will not   work.

If you are going to create a Cursor to access the data you should use _id

Cursor c = db.query("....");
    
answered by 05.06.2016 / 22:00
source