我有一个SQLite虚拟表,我意识到它不会自动递增_id参数,而是反复将值填充为空。
这是我的表格代码
// 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 + ")";
光标的Log消息,用于检查返回的内容
04-16 23:53:17.612:D / MessagingActivity(6313):timestamp = 1397672593064 message =我知道_id = null fromto = 0 read = 0 logged = null agent_id = null agent_name = Aakrit business = 55
记录的且agent_id为null是设计的,但id不是
答案 0 :(得分:1)
问题在于您的列 _id ,它代表每行的唯一标识符。 FTS3表有一个名为 rowid 的特殊列(它是隐藏的),您应该使用该列而不是 _id 列来获取行的标识符。
所以你可以试试这个:
select rowid, * from YourTable
现在它应该像以前一样返回正确的id值而不是null。这是official documentation。 希望,它能解决你所面临的问题。