0
public class RestaurantHelper extends SQLiteOpenHelper{

    public static final String TABLE_RESTAURANTS = "table_restaurants";
    public static final String COL_ID = "ID";
    public static final String COL_NAME = "NAME";
    public static final String COL_ADRESSE = "ADRESSE";
    public static final String COL_GENRE = "GENRE";
    public static final String COL_NOTES = "NOTES";
    public static final String COL_TELEPHONE = "TELEPHONE"; 

    private static final String CREATE_BDD = "CREATE TABLE" + TABLE_RESTAURANTS +
            " (" + COL_ID + "INTEGER PRIMARY KEY AUTOINCREMENT," + COL_NAME + "TEXT NOT NULL," +
            COL_ADRESSE + "TEXT NOT NULL," + COL_GENRE + "TEXT NOT NULL," + COL_NOTES + "TEXT NOT NULL," +
            COL_TELEPHONE + "TEXT NOT NULL);";


    public RestaurantHelper(Context context, String name,CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_BDD);

    }

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

}

我是 android 新手,我收到此错误消息,但我不知道出了什么问题。谢谢。

4

2 回答 2

2

添加所需的空格。

private static final String CREATE_BDD = "CREATE TABLE " + TABLE_RESTAURANTS +
            " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_NAME + " TEXT NOT NULL, " +
            COL_ADRESSE + " TEXT NOT NULL, " + COL_GENRE + " TEXT NOT NULL, " + COL_NOTES + " TEXT NOT NULL, " + COL_TELEPHONE + " TEXT NOT NULL);";
于 2013-07-26T21:57:56.047 回答
0

你的“CREATE TABLE”应该有空格“CRATE TABLE”。注意空间伙伴

于 2013-07-26T21:55:44.797 回答