mardi 29 décembre 2015

Caused by: android.database.sqlite.SQLiteException: near “”: syntax error (code 1): , while compiling:

When running my app, I get this message

E/AndroidRuntime(1209): Caused by:   android.database.sqlite.SQLiteException: near "tablepatients_table": syntax error (code 1): , while compiling: create tablepatients_table(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, FAMILYNAME TEXT, DOB TEXT, ADDRESS TEXT, PHONENUMBER TEXT, EMAIL TEXT)

DatabaseHelper.java code:

public class DatabaseHelper extends SQLiteOpenHelper {

    public static final String DATABASE_NAME="appo.db";
    public static final String TABLE_NAME = "patients_table";
    public static final String COL_1 = "ID";
    public static final String COL_2 = "NAME";
    public static final String COL_3 = "FAMILYNAME";
    public static final String COL_4 = "DOB";
    public static final String COL_5 = "ADDRESS";
    public static final String COL_6 = "PHONENUMBER";
    public static final String COL_7 = "EMAIL";

    public DatabaseHelper(Context context){
        super(context, DATABASE_NAME, null, 1);
        SQLiteDatabase db = this.getWritableDatabase();
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table"+TABLE_NAME+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, FAMILYNAME TEXT, DOB TEXT, ADDRESS TEXT, PHONENUMBER TEXT, EMAIL TEXT)");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS" + TABLE_NAME);
        onCreate(db);

    }

}

Aucun commentaire:

Enregistrer un commentaire