I'm a beginner at SQLite Database making and I had just ran into a problem. I want to be able to completely reCreate my table, so i copied onCreate and renamed it reCreate with the exact same parameteres. What I want to ask is does the SQLiteDatabase that is passed into onCreate has to be a certain SQLite Database, because it seems that reCreate is not working (in a later function, it says "no such table" after using reCreate).
code that calls reCreate:
SQLiteDatabase db = null;
new EventDBHelper (this, 1).reCreate(db);
reCreate code:
//String used to create new player data table
private final String createDB = "CREATE TABLE IF NOT EXISTS " + DB_NAME + " ( "
+ I_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ NAME + " TEXT, "
+ TEXT + " TEXT, "
+ PIC_S + " TEXT, "
+ PIC_E + " TEXT, "
+ POINTS + " TEXT, "
+ PROB + " TEXT "
+ " ) ; ";
//String to delete table
private final String deleteDB = "DROP TABLE IF EXISTS " + DB_NAME;
public void reCreate(SQLiteDatabase db){
//remove
db.execSQL(deleteDB);
//create
db.execSQL(createDB);
//initialize the database
db.insert(DB_NAME, null, insertValuesFromEvent (find_bill));
db.insert(DB_NAME, null, insertValuesFromEvent (find_bill2));
db.insert(DB_NAME, null, insertValuesFromEvent (salary));
}
I didnt find documentation for this.
onCreate()method ?