我似乎找不到有关未创建该列的原因的错误。
public static final String GAME_TABLE = "Game";
public static final String KEY_GAMEID = "_id";
public static final int COL_GAMEID = 0;
public static final String KEY_OPONENT = "opponentTeam";
public static final int COL_OPONENT = 1;
public static final String KEY_GAME_FIRST_PLAYER = "GamePLAYER1";
public static final int COL_GAME_FIRST_PLAYER = 2;
public static final String KEY_GAME_SECOND_PLAYER = "GamePLAYER2";
public static final int COL_GAME_SECOND_PLAYER = 3;
public static final String KEY_FK_GAME = "FKtournament";
public static final int COL_FK_GAME = 4;
public static final String[] ALL_GAME_KEYS = new String[] {
KEY_GAMEID, KEY_OPONENT, KEY_GAME_FIRST_PLAYER, KEY_GAME_SECOND_PLAYER, KEY_FK_GAME};
//THIS IS WHERE I CREATE MY TABLE
// KEY REY_ROWID is from another table
private static final String GAME_TABLE_CREATE_SQL =
"create table " + GAME_TABLE
+ " ("
+ KEY_GAMEID + " integer primary key autoincrement, "
+ KEY_OPONENT + " string not null, "
+ KEY_GAME_FIRST_PLAYER + "string not null, "
+ KEY_GAME_SECOND_PLAYER + "string not null, "
+ KEY_FK_GAME+" INTEGER REFERENCES "+KEY_ROWID
+ ");";
public long insertGAMERow(String opponentTeam, String GamePLAYER1, String GamePlayer2, int key) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_OPONENT, opponentTeam);
initialValues.put(KEY_GAME_FIRST_PLAYER, GamePLAYER1);
initialValues.put(KEY_GAME_SECOND_PLAYER, GamePlayer2);
initialValues.put(KEY_FK_GAME, key);
return db.insert(GAME_TABLE, null, initialValues);
}
以下是错误日志:
08-03 06:27:58.279: I/System.out(3580): true true false
08-03 06:27:58.279: I/Database(3580): sqlite returned: error code = 1, msg = table Game has no column named GamePLAYER1
08-03 06:27:58.289: E/Database(3580): Error inserting opponentTeam=asd GamePLAYER1=asdda asd GamePLAYER2=asd asd FKtournament=1
08-03 06:27:58.289: E/Database(3580): android.database.sqlite.SQLiteException: table Game has no column named GamePLAYER1: , while compiling: INSERT INTO Game(opponentTeam, GamePLAYER1, GamePLAYER2, FKtournament) VALUES(?, ?, ?, ?);
08-03 06:27:58.289: E/Database(3580): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
08-03 06:27:58.289: E/Database(3580): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
08-03 06:27:58.289: E/Database(3580): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
08-03 06:27:58.289: E/Database(3580): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
08-03 06:27:58.289: E/Database(3580): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
08-03 06:27:58.289: E/Database(3580): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1149)
08-03 06:27:58.289: E/Database(3580): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1569)
08-03 06:27:58.289: E/Database(3580): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426)
08-03 06:27:58.289: E/Database(3580): at com.example.beachvolleyball.DBAdapter.insertGAMERow(DBAdapter.java:175)
08-03 06:27:58.289: E/Database(3580): at com.example.beachvolleyball.NewGame$1.onClick(NewGame.java:125)
08-03 06:27:58.289: E/Database(3580): at android.view.View.performClick(View.java:2485)
08-03 06:27:58.289: E/Database(3580): at android.view.View$PerformClick.run(View.java:9080)
08-03 06:27:58.289: E/Database(3580): at android.os.Handler.handleCallback(Handler.java:587)
08-03 06:27:58.289: E/Database(3580): at android.os.Handler.dispatchMessage(Handler.java:92)
08-03 06:27:58.289: E/Database(3580): at android.os.Looper.loop(Looper.java:123)
08-03 06:27:58.289: E/Database(3580): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-03 06:27:58.289: E/Database(3580): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 06:27:58.289: E/Database(3580): at java.lang.reflect.Method.invoke(Method.java:507)
08-03 06:27:58.289: E/Database(3580): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-03 06:27:58.289: E/Database(3580): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-03 06:27:58.289: E/Database(3580): at dalvik.system.NativeStart.main(Native Method)