user903601
user903601

Reputation:

Android updating database in assets folder

I have an app receiving its data from a database in the assets folder. Now everyone has the app on their phones I want to update the database. I have the new database ready to go on a server, but how to I get the updated database into the assets folder on their phones. All only if they want to update of course???

Cheers,

Mike.

Upvotes: 0

Views: 1383

Answers (1)

Caner
Caner

Reputation: 59178

SQLiteOpenHelper constructor has an version argument. If you supply some number that is bigger than the existing database version in phones memory, onUpgrade function will run after getWritableDatabase is called. Inside onUpgrade you should handle updating your database.

Some example code here: Question about onUpgrade method android

Upvotes: 2

Related Questions