0

I get a syntax error when I create a four rows table in my SQLite and I don't know why. This is my code.

 private static final String TABLE_PRIMERO = "jugadors";

// Jugadors Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_ALTURA = "altura";
private static final String KEY_PARTIDO = "partido";

int oldVersion=1;

public DatabaseHandler(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {

    String CREATE_JUGADORS_TABLE1 = "CREATE TABLE_PRIMERO " + TABLE_PRIMERO + "("
            + KEY_ID + " INTEGER PRIMARY KEY,"
            + KEY_NAME + " TEXT,"
            + KEY_ALTURA + " TEXT,"
            + KEY_PARTIDO + " TEXT"
            + ")";
    db.execSQL(CREATE_JUGADORS_TABLE1);


}

//Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // Drop older table if existed
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_PRIMERO);

    // Create tables again
    onCreate(db);
}

I don't know what i'm doing wrong.

Thanks in advance.

1 Answer 1

2
String CREATE_JUGADORS_TABLE1 = "CREATE TABLE_PRIMERO " + TABLE_PRIMERO + "("
        + KEY_ID + " INTEGER PRIMARY KEY,"
        + KEY_NAME + " TEXT,"
        + KEY_ALTURA + " TEXT,"
        + KEY_PARTIDO + " TEXT"
        + ")";

This should be something like

String CREATE_JUGADORS_TABLE1 = "CREATE TABLE " + TABLE_PRIMERO + "("
        + KEY_ID + " INTEGER PRIMARY KEY,"
        + KEY_NAME + " TEXT,"
        + KEY_ALTURA + " TEXT,"
        + KEY_PARTIDO + " TEXT"
        + ")";

The TABLE is a keyword with a specific meaning.

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.