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).
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
?