vergil corleone
vergil corleone

Reputation: 1111

Programatically update SQLite database in android?

I have around 2600 entries in my SQLite database. I need to delete all those entries and put in updated entries. I know that the database can be updated by changing the database version in the DatabaseHandler class, but that can only be done if the whole app is updated. I need to programatically update the database. Can this be done? I searched but couldn't find a satisfactory answer. Thanks.

Upvotes: 0

Views: 1011

Answers (1)

MDMalik
MDMalik

Reputation: 4001

I guess you can call a method some what like this

public void emptyDatabase() {
    db = this.getWritableDatabase();
    db.execSQL("DELETE FROM " + TABLE_Your_Tbl);
}

Even this will be able to delete those values quickly. Without updating the version number.

Plus as you mentioned that you have to delete the records and add new values. It will be much faster that updating those values.

Upvotes: 1

Related Questions