我在sqlite中创建了一个表,给了我java.lang.ArrayIndexOutOfBoundsException这是代码:
db.execSQL("CREATE TABLE "+scoreboardTable+" ("+scoreboard_id+ " INTEGER PRIMARY KEY NOT NULL,"+" FOREIGN KEY ( "+player_fk+ ") REFERENCES "+playerTable+" ("+playerid+ "), "
+"FOREIGN KEY ( "+ Template_fk+ ") REFERENCES " +TemplateTable+" ("+ templateid+ "),"+ total_flick+"int"+surprise_success+"varchar"+surprise_failure+"varchar)");
}
和
public void Insert_scoreboard(String[] str)
{
try
{
SQLiteDatabase DB= this.getWritableDatabase();
ContentValues cv=new ContentValues();
cv.put("scoreboard_id", str[0]);
cv.put("player_fk", str[1]);
cv.put("Template_fk", str[2]);
cv.put("total_flick", str[3]);
cv.put("surprise_success", str[4]);
cv.put("surprise_failure", str[5]);
DB.insert( scoreboardTable , "scoreboard", cv);
DB.close();
}
catch(Exception ex)
{
ex.toString();
}
我做错了.
您在Create Table Syntax
中出错(您忘记了逗号,在某些地方)使用以下代码更新您的代码,
db.execSQL( "CREATE TABLE " + scoreboardTable + " (" + scoreboard_id + " INTEGER PRIMARY KEY NOT NULL," + " FOREIGN KEY ( "+player_fk+ ") REFERENCES " + playerTable + " (" + playerid + "), " + "FOREIGN KEY ( " + Template_fk + ") REFERENCES " + TemplateTable + " (" + templateid + ")," + total_flick + "int, " + surprise_success + "varchar, " + surprise_failure + "varchar)" );
}