我不知何故无法创建新表。我检查了我的语法并搜索了其他人有相同的错误,但我无法找到错误。
private static final String DATABASE_NAME = "food_database";
private static final String TABLE_NAME = "food_table";
private static final String UID = "_id";
private static final String CALORIE_COLUMN = "Calorie";
private static final String FOOD_COLUMN = "Food";
private static final int DATABASE_VERSION = 4;
private static final String CREATE_TABLE = "CREATE TABLE "+TABLE_NAME+" ("+UID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+CALORIE_COLUMN+" FLOAT , "+FOOD_COLUMN+" text not null);";
private static final String DROP_TABLE = "DROP TABLE IF EXISTS "+TABLE_NAME;
private Context context;
public FoodHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context;
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
try {
sqLiteDatabase.execSQL(CREATE_TABLE);
} catch (SQLException e) {
Log.e("HEY","Error creating");
e.printStackTrace();
}
}