0

I'm trying to use SQlite but this error comes up:

E/SQLite Exception: near ")": syntax error (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE IF NOT EXISTS contact ( _id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, organization TEXT, phone INTEGER, address TEXT, email TEXT, web_ad TEXT, inf TEXT, birthday TEXT NULL, )

And I guess it should be this part of my code:

    public static final String SQL_CREATE_ENTRIES = "" +
        "CREATE TABLE IF NOT EXISTS " + ContactHelper.TABLE +" ( "+
        ContactHelper._ID +" INTEGER PRIMARY KEY AUTOINCREMENT, "+
        ContactHelper.COL_NAME +" TEXT, "+
        ContactHelper.COL_ORGANIZATION +" TEXT, "+
        ContactHelper.COL_PHONE +" INTEGER, "+
        ContactHelper.COL_ADDRESS +" TEXT, "+
        ContactHelper.COL_EMAIL + " TEXT, " +
        ContactHelper.COL_WEB + " TEXT, " +
        ContactHelper.COL_INF + " TEXT, " +
        ContactHelper.COL_BIRTH + " TEXT NULL, " +
        " ) ";

it's odd because at first SQL_CREATE_ENTRIES was like below and there was no error, once I added a couple of more columns, that error came up.

    public static final String SQL_CREATE_ENTRIES = "" +
        "CREATE TABLE IF NOT EXISTS " + ContactHelper.TABLE +" ("+
        ContactHelper._ID +" INTEGER PRIMARY KEY AUTOINCREMENT, "+
        ContactHelper.COL_NAME +" TEXT, "+
        ContactHelper.COL_ORGANIZATION +" TEXT NULL, "+
        ContactHelper.COL_PHONE +" INTEGER, "+
        ContactHelper.COL_ADDRESS +" TEXT NULL"+
        ")";

I've looked at similar questions, they all say that there should be a space before and after words but it didn't work.

1 Answer 1

3

You have extra ',' at the end of your query at this line TEXT NULL, )

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.