Reputation: 921
I've got an SQLite Virtual Table that I realized isn't auto incrementing the _id parameter, instead filling the value as null repeatedly.
Here is my code for the table
// Chat History Table
public static String ID = "_id";
public static String MESSAGE = "message";
public static String BUSINESS = "business";
public static String TIMESTAMP = "timestamp";
public static String FROMTO = "fromto";
public static String READ = "read";
public static String LOGGED = "logged";
public static String AGENT = "agent_id";
public static String AGENT_NAME = "agent_name";
// Logging Values
public static int LOG_SENDING = 2;
public static int LOG_SENT = 1;
public static int LOG_FAILED = 0;
public static final String TABLE_CREATE = "CREATE VIRTUAL TABLE " + TABLE
+ " USING fts3 (" + ID + " INTEGER PRIMARY AUTOINCREMENT, " + READ
+ ", " + BUSINESS + ", " + MESSAGE + ", " + TIMESTAMP + ", "
+ AGENT_NAME + ", " + AGENT + ", " + LOGGED + ", " + FROMTO + ")";
The Log message of the cursor to check what is being returned
04-16 23:53:17.612: D/MessagingActivity(6313): timestamp=1397672593064 message=I know _id=null fromto=0 read=0 logged=null agent_id=null agent_name=Aakrit business=55
The logged and agent_id being null is by design, but the id isn't
Upvotes: 1
Views: 345
Reputation: 33505
Problem is with your column _id that represents unique identificator of each row. FTS3 tables have special column (it's hidden) called rowid and you should use that column instead of _id column to get row's identificator.
So you can try this:
select rowid, * from YourTable
and now it should return correct id value and not null as before. Here is official documentation. Hope, it'll solve your problem you're facing.
Upvotes: 1