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.

Reply via email to