我正在尝试创建两个表,其中一个表的键是另一个表上的键,这样我就可以创建一行到多个表。这是我的oncreate代码。
private static final String MESSAGE_TABLE_CREATE =
"CREATE TABLE " + MESSAGE_HISTORY + " (" +
MSG_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
TASK_ID + " INTEGER, " +
RECEIVER + " TEXT, " +
SENDER + " TEXT, " +
CHAT_MSG + " TEXT, " +
SHOWUTCDATE + " TEXT, " +
FLAG + " TEXT, " +
NEWTIMESTAMP + " TEXT, " +
LAT + " TEXT, " +
LON + " TEXT, " +
IMAGE_URL + " TEXT, " +
DESTINATION + " TEXT, " +
ATTACHMENT_ID + " TEXT, " +
MIME + " TEXT, " +
SIZE + " TEXT, " +
EXTENSION + " TEXT, " +
IS_ACCEPTED + " TEXT, " +
USER_ID + " TEXT " +
")";
private static final String VENDOR_TABLE_CREATE =
"CREATE TABLE " + VENDORS + " (" +
VENDOR_ID + " INTEGER PRIMARY KEY, " +
TASK_ID + "INTEGER, " +
RECEIVER + " TEXT, " +
SENDER + " TEXT, " +
VENDOR_NAME + " TEXT, " +
VENDOR_CONTENT + " TEXT, " +
VENDOR_STAR + " TEXT, " +
VENDOR_ADDRESS + " TEXT, " +
VENDOR_COMMENTS + " TEXT, " +
VENDOR_DISTANCE + " TEXT, " +
MOBILE + " TEXT, " +
PHONE + " TEXT, " +
LAT + " TEXT, " +
LON + " TEXT, " +
JUDESAYS + " TEXT " +
")";
public TasksDBOpenHelper (Context context){
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db){
db.execSQL(CURRENT_TABLE_CREATE);
db.execSQL(HISTORY_TABLE_CREATE);
db.execSQL(MESSAGE_TABLE_CREATE);
db.execSQL(VENDOR_TABLE_CREATE);
}
出于某种原因,在供应商表上列#34; TASK_ID"没有创建。
答案 0 :(得分:1)
你错过了TASK_ID
&之间的空格。单词INTEGER
。
应为TASK_ID + " INTEGER, " +