in order to keep my program working the update routine works as follows
for every table that has to be updated
-
CREATE TABLE new(table Name)
-
CREATE INDEX on new(table Name)
-
Fill new(table Name) with data
if they all are successfully filled for every table that has to be updated
-
DROP table (table Name)
-
rename new(table Name) to (table Name)
after creating the database the first time it works perfect and is fast ( size ~14MB )
after updating the database (same data) it suddenly works slow and it is smaller in size ( size ~10MB )
actual code create table:
//new table name
String newTable = "new" + TABLE_GAME_INCLUDED;
//remove any previous version of table
db.execSQL("DROP TABLE IF EXISTS " + newTable );
//create empty table
String CREATE_NEW_TABLE = "CREATE TABLE " + newTable + " ( " +
GAME_INCLUDED_POSITION_ID + " INTEGER, " +//not unique
GAME_INCLUDED_MIN_GAME_ID + " INTEGER, " +//not unique
GAME_INCLUDED_MAX_GAME_ID + " INTEGER )"; //not unique
db.execSQL(CREATE_NEW_TABLE);
//create index
db.execSQL( "CREATE INDEX IF NOT EXISTS index_min_game ON " +
newTable + " ( " + GAME_INCLUDED_POSITION_ID + " )" );
actual code for removing old table and renaming new table
//drop tableName database
db.execSQL("DROP TABLE IF EXISTS " + tableName );
//change new[tableName] to tableName
db.execSQL( "ALTER TABLE new" + tableName + " RENAME TO " + tableName );
any thoughts on what is wrong? or should i use a different way of updating my database?
Aucun commentaire:
Enregistrer un commentaire