在SQLite中创建表

时间:2015-11-02 15:40:45

标签: android sqlite

我正在尝试在SQLite中创建两个表,但应用程序一直在崩溃 以下是我的代码

   public void onCreate(SQLiteDatabase database) {

    String queryUser_Details = "CREATE TABLE user_details ( user_Id INTEGER PRIMARY KEY, name TEXT, " +
            "gender TEXT, hairColor TEXT, weight TEXT, height TEXT, age TEXT, comment TEXT)";

    database.execSQL(queryUser_Details);

    String queryUser_Activity =
            "CREATE TABLE user_activity ( detail_Id INTEGER PRIMARY KEY, time TEXT, location TEXT, note TEXT, FOREIGN KEY(user_Id) REFERENCES user_details(user_Id))";

    database.execSQL(queryUser_Activity);

}

1 个答案:

答案 0 :(得分:0)

REFERENCE 拼写错误:需要最终的S:参考
供参考(哦!多么有趣的笑话!):https://www.sqlite.org/foreignkeys.html