aravind
aravind

Reputation: 427

Android:Upgrading database

I have an app containing database structure.I need to update the version with new database structure that it contains changes in columns,removal of columns.deletion of columns.Is this really possible for the change in existing database structure.If it is possible means,where i have to do the changes in the app code?

Shall i need to create the new database structure and do the rest in Upgrade event or Do i need to do changes only in upgrade event?

Upvotes: 0

Views: 95

Answers (2)

Yaqub Ahmad
Yaqub Ahmad

Reputation: 27659

You can do it in SQLiteOpenHelper's onUpgrade() event, like:

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
        db.execSQL("DROP TABLE ....");
        db.execSQL("ATER TABLE ....");
        onCreate(db);
    }

Upvotes: 1

Josnidhin
Josnidhin

Reputation: 12504

Take a look at the SQLiteOpenHelper Class

Upvotes: 1

Related Questions