1

can someone tell me if this is correct please?

public static final String DATABASE_CREATE = ("CREATE TABLE" + TABLE_NAME + "(" +
                                            COLUMN_ID + "INTEGER PRIMARY KEY AUTOINCREMENT,"+ 
                                            COLUMN_TITLE + "text not null," + 
                                            COLUMN_CATEGORY + "text not null," + 
                                            COLUMN_IMAGE + "text not null);");

the error is SQLiteException

2 Answers 2

4

You are missing space between columns and table name. Here is corrected query:

"CREATE TABLE " + TABLE_NAME + "(" +
 COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"+ 
 COLUMN_TITLE + " text not null," + 
 COLUMN_CATEGORY + " text not null," + 
 COLUMN_IMAGE + " text not null);");

Also, take care about semi-colon at the end of query. It's very problematic - i mean on some devices this symbol may cause error (safer is to don't use it).

Hope i helped you to solve your problem.

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

1 Comment

where exactly shall i put the space?
2
COLUMN_TITLE + "text not null" this is your mistake, 

Add a space at your column's data type like below,

public static final String DATABASE_CREATE = ("CREATE TABLE" + TABLE_NAME + "(" +
                                            COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"+ 
                                            COLUMN_TITLE + " text not null," + 
                                            COLUMN_CATEGORY + " text not null," + 
                                            COLUMN_IMAGE + " text not null);");

You were missing a space between your column name and its data type.

1 Comment

what is exactly the mistake please?

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.