0

I'm developing a database for my app and when I try to add a new user into the database I get this error

android.database.sqlite.SQLiteException: near "CREATE": syntax error while

I've looked at other questions and seen that the spacing and quote positioning is very important. But looking at other working examples mine's seems to be correct?

My class below

    private static final String TABLE_NAME = "FITNESSMATETABLE";
    private static final String DATABASE_NAME = "fitnessmatedatabase";

    private static final String USERID = "_id";
    private static final String NAME = "Name";
    private static final String PASSWORD = "Password";

    //Database Version
    private static final int DATABASE_VERSION = 18;

    //The database strings themselves
private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME
        + " (" + USERID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + NAME
        + " TEXT, " + PASSWORD + " TEXT);";

Looking at the error I believe it's telling me that the quotations around "CREATE" are wrong. Can anyone see anything out of the ordinary?

Thanks in advance

1
  • 1
    Please post full exception and stacktrace. Commented May 9, 2014 at 4:33

2 Answers 2

2

Varcars aren't available in sqlite. Trying replacing them with TEXT. Check here for sqlite data types http://www.sqlite.org/datatype3.html

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

Comments

-1

The following syntax will work for you

create table FITNESSMATETABLE (_id integer primarykey auto increment,Name text,password text);

4 Comments

unfortunately I'm still getting the same error with that syntax. I'll keep trying here, Thanks
Change your code , and directly write private static final String CREATE_TABLE="create table FITNESSMATETABLE (_id integer primarykey auto increment,Name text,password text);"
code private static final String CREATE_TABLE="create table FITNESSMATETABLE (_id integer primarykey auto increment,Name text,Password text);";code still getting the same error
Then, that is not the syntax issue. This will come if DB is not create properly . Please check your DB creation

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.