0

I want to make db version control for Sqlite .db file which is inside my asset folder Manually without Google play app store. (as its custom app for user). First deployment I have db version 1.00 after that Second deployment I have version 1.01 with some DB file changes for column name or type changes in certain table.

How can i achieve without uninstalling db from installed app. just replacing existing DB for particular column?

Also don't want to loose users data.(as there are some master tables).

please see this answer too .

Question1

Question2

Community
  • 1
  • 1
Aditi K
  • 1,534
  • 5
  • 22
  • 43
  • you cannot have both: copy-from-asset and preserve data. if you want to preseve the data the app is using you need incremental sql-migration scripts that convert database schema/content from version 1.00 to 1.01 containing create/alter table statements. if your update consists of "copy database from asset-folder" you will loose your current data. Mybe you can generate the increment script as described in http://stackoverflow.com/questions/4580368/how-can-i-diff-2-sqlite-files – k3b Sep 30 '14 at 11:50

1 Answers1

1

You need to do a request like SELECT * FROM TABLE_NAME to all your tables and save getting data as string in any file.

QArea
  • 4,955
  • 1
  • 12
  • 22
  • so i suppose to keep result on local b4 upgrading existing db .then again read that stored file data and write it to new upgraded file ? Isn't it too heavy ? – Aditi K Oct 01 '14 at 06:12
  • @AditiK that's not the right way, you should update db in onCreate method in db helper. In your db it will be easier to drop all and create new db as you've written. – QArea Oct 02 '14 at 13:10
  • thnks for help. I am using onUpgrade method to increment DB version Its working fone now – Aditi K Oct 07 '14 at 05:27