public static final String MYDATABASE_NAME = "MY_DATABASE";
public static final String MYDATABASE_TABLE = "MY_TABLE";
public static final int MYDATABASE_VERSION = 1;
public static final String KEY_ID = "_id";
public static final String KEY_CONTENT = "Content";
public static final String DRINK_NAME = "Name";
public static final String DRINK_CATEGORY = "Category";
public static final String DRINK_COLOR = "Color";
public static final String DRINK_TYPE = "Type";
public static final String INGREDIENT_1="In1", INGREDIENT_2="In2", INGREDIENT_3="In3", INGREDIENT_4="In4",
INGREDIENT_5="In5", INGREDIENT_6="In6";
public static final String TIME_1="T1", TIME_2="T2", TIME_3="T3", TIME_4="T4", TIME_5="T5", TIME_6="T6";
//create table MY_DATABASE (ID integer primary key, Content text not null);
private static final String SCRIPT_CREATE_DATABASE =
"CREATE TABLE IF NOT EXISTS " + MYDATABASE_TABLE + " ("
+ DRINK_NAME + " TEXT, " + DRINK_CATEGORY + " TEXT, "
+ DRINK_COLOR + " TEXT, " + DRINK_TYPE + " TEXT, "
+ INGREDIENT_1 + " TEXT, " + INGREDIENT_2 + " TEXT, "
+ INGREDIENT_3 + " TEXT, " + INGREDIENT_4 + " TEXT, "
+ INGREDIENT_5 + " TEXT, " + INGREDIENT_6 + " TEXT, "
+ TIME_1 + " TEXT, " + TIME_2 + " TEXT, "
+ TIME_3 + " TEXT, " + TIME_4 + "TEXT, "
+ TIME_5 + " TEXT);";
我不断收到错误“表 MYDATABASE_TABLE 没有名为 T4 的列”显然,我有一个名为 TIME_4 的列,它是“T4”的变量名
然后我在此处插入值:
public long insert(String name, String category, String color, String type, String ingredient1,
String ingredient2, String ingredient3, String ingredient4, String ingredient5,
String ingredient6, int time1, int time2, int time3, int time4, int time5){
ContentValues contentValues = new ContentValues();
contentValues.put(DRINK_NAME, name);
contentValues.put(DRINK_CATEGORY, category);
contentValues.put(DRINK_COLOR, color);
contentValues.put(DRINK_TYPE, type);
contentValues.put(INGREDIENT_1, ingredient1);
contentValues.put(INGREDIENT_2, ingredient2);
contentValues.put(INGREDIENT_3, ingredient3);
contentValues.put(INGREDIENT_4, ingredient4);
contentValues.put(INGREDIENT_5, ingredient5);
contentValues.put(INGREDIENT_6, ingredient6);
contentValues.put(TIME_1, time1);
contentValues.put(TIME_2, time2);
contentValues.put(TIME_3, time3);
contentValues.put(TIME_4, time4);
contentValues.put(TIME_5, time5);
// contentValues.put(TIME_6, time6);
return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
}
谁能告诉我我做错了什么?我是 SQLite 的新手