0

this is my code to create database table:

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);
        }   
}

but I have an error in the 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);

I don't understand why this error. Could someone help me to understand? (sorry for my bad english).

1 Answer 1

3

Remove create from date create TEXT NOT NULL. You seem to have added it by mistake.

Looks like Key_date_create has the value date create, maybe you meant date_create?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.