0

这是我创建数据库表的代码:

public void onCreate(SQLiteDatabase db) {
        Log.i(TAG, "Inizio creazione database MessagesDB");
        String CREATE_TABLE = "CREATE TABLE " + TABLE2 + " (" + Key_key + " TEXT PRIMARY KEY, " + Key_ID + " INTEGER NOT NULL, " + Key_author + " TEXT NOT NULL, " 
+ Key_date_create + " TEXT NOT NULL, " + Key_sender + " TEXT, " 
+ Key_date_sent + " TEXT, " + Key_recipient + " TEXT, " 
+ Key_date_received + " TEXT, " + Key_message + " TEXT, " 
+ Key_message_path + " TEXT, " + Key_size + " INTEGER" + ");";  
        try {
            db.execSQL(CREATE_TABLE); 
            Log.i(TAG, "Creazione database MessagesDB avvenuta con successo");
        }
        catch (Exception e){
            Log.e(TAG, "Errore nella create table messages", e);
        }   
}

但我在 logcat 中有一个错误:

:Errore nella create table messages
:android.database.sqlite.SQLiteException: near "create": syntax error: CREATE TABLE messagesDB (_key TEXT PRIMARY KEY, _id INTEGER NOT NULL, author TEXT NOT NULL, date create TEXT NOT NULL, sender TEXT, date_sent TEXT, recipient TEXT, date_received TEXT, message TEXT, message_path TEXT, size INTEGER);

我不明白为什么会出现这个错误。有人可以帮我理解吗?(对不起,我的英语不好)。

4

1 回答 1

3

create从中删除date create TEXT NOT NULL。您似乎是错误地添加了它。

看起来Key_date_create有价值date create,也许你的意思是date_create

于 2013-01-19T16:07:50.327 回答