0
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という名前の列がありません」というエラーが表示され続けます明らかに、「T4」の変数名であるTIME_4という名前の列があります

次に、ここに値を挿入します。

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が初めてです

4

1 に答える 1

2

変化する

  + TIME_3 + " TEXT, " + TIME_4 + "TEXT, " 

+ TIME_3 + " TEXT, " + TIME_4 + " TEXT, " 

TIME_4 と の間にスペースを入れるのを忘れているためTEXT,

于 2012-12-29T19:49:28.037 に答える