我在Android上用sqlite实现了一个数据库,但它不起作用,我不知道为什么......你能帮我一点儿吗?这是我的第一次。
当我要添加数据时,我有这个错误:
E / SQLiteLog:(1)表table_GAME没有名为_id_game的列
我的代码:
public class BaseSQL extends SQLiteOpenHelper {
private static final int VERSION_BDD = 1;
private static final String NOM_BDD = "games.db";
private static final String TABLE_GAME = "table_GAME";
private static final String COL_ID = "_id";
private static final String COL_ID_GAME = "_id_game";
private static final String COL_NB_JOUEURS = "Nb_joueurs";
private static final String COL_ID_TOUR = "Numéro_du_tour";
private static final String COL_PRENEUR = "Preneur";
private static final String COL_CONTRAT = "Contrats";
private static final String COL_BOUTS = "Bouts";
private static final String COL_PETIT = "Petit";
private static final String COL_21 = "vingt_un";
private static final String COL_ESXCUSE = "Escuse";
private static final String COL_POINTS = "Points";
private static final String COL_JOUEUR_APPELE = "Joueurs_appele";
private static final String COL_JOUEUR_1 ="j1";
private static final String COL_JOUEUR_2="j2";
private static final String COL_JOUEUR_3="j3";
private static final String COL_JOUEUR_4="j4";
private static final String COL_JOUEUR_5="j5";
private static final String TABLE_JOUEURS ="table_JOUEURS";
private static final String COL_ID_JOUEURS ="id_du_joueur";
private static final String COL_NOMS_JOUEURS ="nom_du_joueur";
private static final String Table1 = "CREATE TABLE " + TABLE_GAME + " ("+
COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ COL_ID_GAME +" INTEGER, "
+ COL_NB_JOUEURS +" INTEGER, "
+ COL_ID_TOUR + " INTEGER, "
+ COL_PRENEUR + " INTEGER, "
+ COL_CONTRAT + " TEXT NOT NULL, "
+ COL_BOUTS + " TEXT NOT NULL, "
+ COL_PETIT+ " TEXT NOT NULL, "
+ COL_21+" TEXT NOT NULL, "
+ COL_ESXCUSE+" TEXT NOT NULL, "
+ COL_POINTS+" INTEGER, "
+ COL_JOUEUR_APPELE +" INTEGER, "
+ COL_JOUEUR_1+" INTEGER, "
+ COL_JOUEUR_2+" INTEGER, "
+ COL_JOUEUR_3+" INTEGER, "
+ COL_JOUEUR_4+" INTEGER, "
+ COL_JOUEUR_5+" INTEGER "+");";
private static final String Table2 ="CREATE TABLE '"+ TABLE_JOUEURS +"' ('" +
COL_ID_JOUEURS+"' INTEGER PRIMARY KEY AUTOINCREMENT, '"
+ COL_NOMS_JOUEURS+ "' TEXT NOT NULL);";
public BaseSQL(Context context) {
super(context, NOM_BDD, null, VERSION_BDD);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(Table1);
db.execSQL(Table2);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(BaseSQL.class.getName(),
"Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE " + TABLE_GAME + ";");
db.execSQL("DROP TABLE " + TABLE_JOUEURS + ";");
onCreate(db);
}
}