I'm trying to add some columns to my SQLite database. I keep having the following error:
no such column: n_livello (eg. the new column I'm adding)
and the app installation fails with timeout.
It seems that onUpgrade() method is never called.
This is my code:
public class DBHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "geko";
static final int DATABASE_VERSION = 2;
public DBHelper(Context context){
super(context, DATABASE_NAME , null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_FRA_TABLE = "CREATE TABLE IF NOT EXISTS "+ FRA_TABLE_NAME + " ("
+ FRA_COLUMN_ID + " INTEGER PRIMARY KEY, "
+ FRA_COLUMN_USERNAME + " TEXT, "
+ FRA_COLUMN_NUM_LIVELLO + "INTEGER, "
+ FRA_COLUMN_LIVELLO + " TEXT, "
+ FRA_COLUMN_TEMPO + " TEXT, "
+ FRA_COLUMN_DATA_PARTITA + " TEXT,"
+ FRA_COLUMN_INVIATO + " INTEGER)";
db.execSQL(CREATE_FRA_TABLE);
String CREATE_ING_TABLE = "CREATE TABLE IF NOT EXISTS "+ ING_TABLE_NAME + " ("
+ ING_COLUMN_ID + " INTEGER PRIMARY KEY, "
+ ING_COLUMN_USERNAME + " TEXT, "
+ ING_COLUMN_NUM_LIVELLO + "INTEGER, "
+ ING_COLUMN_LIVELLO + " TEXT, "
+ ING_COLUMN_TEMPO + " TEXT, "
+ ING_COLUMN_DATA_PARTITA + " TEXT,"
+ ING_COLUMN_INVIATO + " INTEGER)";
db.execSQL(CREATE_ING_TABLE);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS "+ FRA_TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS "+ ING_TABLE_NAME);
onCreate(db);
}
}
Thanks for the help.
Aucun commentaire:
Enregistrer un commentaire