SQlite – Android – 外键语法

我一直在试图让外键在我的Android sqlite数据库中工作。我试过下面的语法,但它给了我一个力close:
private static final String TASK_TABLE_CREATE = "create table "
            + TASK_TABLE + " (" + TASK_ID
            + " integer primary key autoincrement," + TASK_TITLE
            + " text not null," + TASK_NOTES + " text not null,"
    + TASK_DATE_TIME + " text not null,FOREIGN KEY ("+TASK_CAT+") REFERENCES "+CAT_TABLE+" ("+CAT_ID+"));";

任何想法我可能做错了什么?如果你需要看到其他表结构,那么我可以,它只是一个非常简单的结构,第二个具有ID和名称

编辑:

这里是错误

03-13 13:42:35.389:
ERROR/AndroidRuntime(312): Caused by:
android.database.sqlite.sqliteException:
unkNown column “taskCat” in foreign
key deFinition: create table reminders
(_id integer primary key
autoincrement,task_title text not
null,notes text not null,
reminder_date_time text not null,
FOREIGN KEY (taskCat) REFERENCES
category (_id));

您必须首先定义TASK_CAT列,然后在其上设置外键。
private static final String TASK_TABLE_CREATE = "create table "
        + TASK_TABLE + " (" 
        + TASK_ID + " integer primary key autoincrement," 
        + TASK_TITLE + " text not null," 
        + TASK_NOTES + " text not null,"
        + TASK_DATE_TIME + " text not null,"
        + TASK_CAT + " integer,"
        + " FOREIGN KEY ("+TASK_CAT+") REFERENCES "+CAT_TABLE+"("+CAT_ID+"));";

更多信息,你可以找到sqlite外键doc

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能