0

Caused by: android.database.sqlite.SQLiteException: near "text": syntax error (code 1): , while compiling: create table contacts (id integer primary key , name text , email text , uname text , pass text)

Thought it might have been, spacing issues at first but doesn't seem to be the problem. keep having problems with this login/register activities.

public class DatabaseHelper extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "contacts.db";
private static final String TABLE_NAME = "contacts";
private static final String COLUMN_ID = "id";
private static final String COLUMN_NAME = "name";
private static final String COLUMN_EMAIL = "email";
private static final String COLUMN_UNAME = "uname";
private static final String COLUMN_PASS = "pass";
SQLiteDatabase db;
private static final String TABLE_CREATE ="create table contacts (id integer primary key , name text ," +
        " email text , uname text , pass text ";
2
  • In other words, you're asking why the code you've not shown us is throwing this exception. This is a very difficult type of question to answer, and you might want to make it easier by posting your Minimal, Complete, and Verifiable example code with your question. Commented May 2, 2017 at 19:35
  • Hey sorry about that, just edited it now adding the table being created, I believe that's where the error is, if not I can add the rest. Commented May 2, 2017 at 19:45

1 Answer 1

3

You forgot a ) at the end of your create table.

The exception you posted does not have that problem, and the SQL there is valid. The error message points to the last valid token the sqlite engine was able to see i.e. text.

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

1 Comment

Ah! Thank you so much, couldn't spot that to save my life!

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.