Mintoris

Author Topic: Overwriting Data Files on Update  (Read 1807 times)

hoyoyo80

  • Full Member
  • ***
  • Posts: 66
Overwriting Data Files on Update
« on: Apr 23, 2016, 01:12 AM »
Thanks

Can i add something? How can i update certain data files and exclude unwanted files. Since my default apk contain default sqlite db and my staff might have their own added data to the database that later on will be replace by updated apk. Can i choose to exclude the db?
Thanks

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Overwriting Data Files on Update
« Reply #1 on: Apr 23, 2016, 02:04 AM »
Once your default.db is installed, never modify it. Instead copy it to a new file and use the copy as your initial database. That way your default.db can change at any time, but the default.db file is only used when you want to create a new database.

hoyoyo80

  • Full Member
  • ***
  • Posts: 66
Overwriting Data Files on Update
« Reply #2 on: Apr 24, 2016, 08:40 PM »
Hrm.. again chuck?

Let say i have two files in my data files,sqlite.db and entry.html, i compile than export it as zip and then using android studio to create apk.
Let say my staff use my app and started to collect datas and request for change of UI in entry.html, so i altered the entry.html but now how can i update their apps without changing their sqlite.db that already have the data and update only the entry.html.

Thanks Chucks

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Overwriting Data Files on Update
« Reply #3 on: Apr 24, 2016, 08:54 PM »
In your new updated app change the name of the sqlite.db to something like install.db.

Then in your program at the start say:


if isFile("install.db") then
  if not isFile("sqlite.db") then
    copy "install.db", "sqlite.db"
  endif
  delete "install.db"
endif


The file will only be copied if it does not exist.

hoyoyo80

  • Full Member
  • ***
  • Posts: 66
Overwriting Data Files on Update
« Reply #4 on: Apr 25, 2016, 11:27 PM »
Thanks Chuck..that solved it  ;D