0
我不知何故無法創建新表。我檢查了我的語法並搜索了其他有相同錯誤的人,但我找不到錯誤。E/SQLiteLog:(1)靠近「,」:語法錯誤
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();
}
}
它的工作!非常感謝。 – wonderland0422