Yes, Based on the database version, you can change whatever you want, however there are some limitations with what you ca do to your table structures. The data, well, you have full control over that.
However, this won't be triggered as soon as your app is updated. You should do some DB initialization activity to trigger this. Mark's method is a better one if you want to deal with data other than those in your DB, like temp files etc. Thanks and Regards, Kumar Bibek On Apr 14, 4:44 pm, gcstang <[email protected]> wrote: > So this would get fired when you increment your database version? > > On Apr 13, 9:35 pm, NoImJosh <[email protected]> wrote: > > > If you're trying to create a more robust database, you don't have to > > delete the existing one. If you have a class that extends > > SQLiteOpenHelper, you can call the following function (this moves data > > from current table to temp table to remove whichever columns you don't > > specify in the "swap" string, drops current table, renames temp to > > original): > > > public void onUpgrade(SQLiteDatabase db, int oldVersion, int > > newVersion) { > > Log.w(TAG, "Upgrading database from version " + oldVersion > > + " to " > > + newVersion + ", which will drop column_A"); > > > String tempDB = "create table temp (" + KEY_ROWID + " > > integer > > primary key autoincrement, " + KEY_NAME + " text not null;"; > > db.execSQL(tempDB); > > String swap = "insert into temp SELECT " + KEY_ROWID + "," + > > KEY_NAME + " FROM " + DATABASE_TABLE; > > db.execSQL(swap); > > db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE); > > db.execSQL("ALTER TABLE temp RENAME TO " + > > DATABASE_TABLE); > > } > > > If you want to add columns to your existing database, it's even > > simpler: > > > public void onUpgrade(SQLiteDatabase db, int oldVersion, int > > newVersion) { > > Log.w(TAG, "Upgrading database from version " + oldVersion > > + " to " > > + newVersion + ", which adds SMS, MMS, Bluetooth, > > & WiFi"); > > String ADD_COLUMN = "ALTER TABLE " + DATABASE_TABLE + " ADD > > column " + KEY_NEWCOLUMN + " TEXT NOT NULL DEFAULT \"The Default\";"; > > db.execSQL(ADD_COLUMN); > > > } > > > On Apr 13, 7:22 pm, eric <[email protected]> wrote: > > > > I want to force the User Data to be deleted on Application upgrade (to > > > delete internal database). > > > How can I do that? > > > > Eric -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.

