2012-05-26 61 views
0

我已創建SQLite中一個表給我java.lang.ArrayIndexOutOfBoundsException 這裏是代碼: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(); 
     } 

如果我做錯了。

回答

1

你有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)"); 
    } 
相關問題