faeze saghafi
faeze saghafi

Reputation: 658

android - update just database content

I publish an android app in app store. After a while I do some edits special in database and move on to next version. My problem is edits and changes in database is just in content and no table nor column are added into it. so the schema is stick and the content is changed. Must I call onUgrade? Should I not change the database version?

Upvotes: 1

Views: 64

Answers (2)

Maryam
Maryam

Reputation: 913

If you use SqliteAssetHelper , You can do like the document says :

Upgrades via overwrite

If you have a read-only database or do not care about user data loss, you can force users onto the latest version of the SQLite database each time the version number is incremented (overwriting the local database with the one in the assets) by calling the setForcedUpgrade() method in your SQLiteAsstHelper subclass constructor.

You can additionally pass an argument that is the version number below which the upgrade will be forced.

Note that this will overwrite an existing local database and all data within it.

Upvotes: 1

Surya Prakash Kushawah
Surya Prakash Kushawah

Reputation: 3201

void onUpgrade (SQLiteDatabase db, 
                int oldVersion, 
                int newVersion)

Called when the database needs to be upgraded. The implementation should use this method to drop tables, add tables, or do anything else it needs to upgrade to the new schema version.

I would like to suggest don't increase database version then not need to call DB onUpgrade methods. If have changed in the schema you should need to call onUpgrade(). And upgrade database version also.

Upvotes: 1

Related Questions