Advice request about application upddates

Wobjoi

New member
Jan 23, 2012
34
0
0
Visit site
Hi everyone.
I am developing my first WP application and have a question of how to handle future updates. I hope some seasoned WP devs can help me out.

The application I am developing uses isolated storage DB to store some data that the user can read through and if they like mark as a favorite which they can go through at any time. These changes are saved back to the DB.

When the application is first executed, I call code to check if the DB exists, if NOT the DB is created and the DB is loaded with some initial data from an XML file. At the end I delete the XML file and am left with a populated DB with all the initial data that the user can browse through each record and mark as favorites. So far all of this is working nicely.

The dilemma I have is how to handle future updates of the application where I will likely add more records to the DB. I don?t want to rebuild an existing DB each time the users executes the application after an update which would overide the records they have marked as favorite.

I need a nice way to ensure that existing users can upgdrade to the newest version and get the latest data appended to the DB while leaving existing records in place and of course new users will need to have all the initial data plus updated data loaded into the DB when the application first executes and the DB is created.

To describe my situation using a example: A existing user upgrades my app from V1.0 to V1.1 and I have added extra records to the XML file that I want appended to the existing DB already loaded with data on the users phone.

I can't drop and re-create the DB and load the data back into it each time the users updates my appliation to a new version as the users changes will be lost each time.

So far the best solution I can come up with is:

1. User installs the application and the first time it is run, a process checks to see if the DB exists. If not, it creates the DB and then loads the DB with the initial data from an XML file stored in a folder called InitialData. When the data is loaded in the DB I delete the XML file from the InitialData folder.

2. A second process executes each time the application loads to check if any updated data files exist in the UpdateData folder which are to be appended to the DB. If so the updated data is loaded and data from the XML file appended to the DB. Again at the end the XML file can be deleted.

3. When the user upgrades to V1.1, and the application loads, it will check to see if the DB exists (as above in step 1). In this instance, the DB will still exists on the users phone with all the initial data loaded so there will be no need to create the DB and load the InitialDB from the InitialData folder. As per step 2 above a process will begin to check if any additional files exists in the UpdateData folder. If it does, the system will load the XML files and append the records to the end of the existing DB, thus not overriding existing records in the system, and of course loading the extra records to the DB.

Any future versions of the application will simply continue to add files to the UpdateData folder so that:

1. New users will always get the initial data (when the application first executes as per step 1) plus the extra data found in the UpdateFolder (as per step 2).
2. Existing users will simply load any new update data file found in the UpdateData folder to their existing DB.

Now the initial data will need to be cumulative meaning that each new version will contain all the data from previous versions in the initial data XML file to be loaded into the DB when it is created. e.g v1.2 will contain the initial data from v1.0 plus the updated data from v1.1.

This is so that updating users don't keep loading updated data file to the DB that the would already have, while new users get all the initial data in one go.

I have run this through and it seems OK, but perhaps their is a better way.

thanks.
 

RogueCode

New member
Apr 16, 2011
76
0
0
Visit site
Hey, and welcome to the forums!

This probably is not the answer you want to hear, but I think your process is about the best. It's relatively clean, you've considered the fact that people can just from 1.0 to 1.3 and just start at 1.3, and it isn't terribly complicated (which means it has less chance to break).

This does ofcourse presume that you make the appending of the DB rock solid, because users would get really cross if they lost all their data.

Depending on the size, there may be a slightly better way. How much data do you see the preloaded getting to?
 

Wobjoi

New member
Jan 23, 2012
34
0
0
Visit site
Hi RogueCode,

thanks for the quick reply. Actually the answer you have given me is great, mostly becuase it supports my idea as being OK. I just was not sure if their was an obvious way of doing it better. Comming from a client server, desktop environment I have not had to consider the challenge of updating data like this before.

I have been putting a lot of thought into it and am still confident that this is the best option for me. Its pretty simple, easy to manage and maintain and should not add much overhead to the application when it is loading as it will simply needs to check if the DB exists. If not create (once off task) and then proceed to step 2 and check to see if their is any new data files to be appended to the DB. Of course I am going to make sure my entire process has no holes in it and that the whole process works well.

As for the amount of data, I don't see it being a lot. At present I am guessing their will be about 4 categories of data and for each category say about 100 records. Each record will simply be a bit of text (varchar 512 at the moment). I also don't plan on changing the DB schema as well so don't have to worry about that potential big issue as well. Will make sure my DB schema stays the way it is and simply add more data to it as the application matures.

I have only 3 tables, the main data table, another table that I use as a reference table and another table that I use for the Main Menu options that ties into the view model.

I was toying with the idea of using some kind of data service to check the web for new data and download it and append it (OTA), but am not confident enough just yet to go down that path. Future applications I do will do that. For now I just want to build up my confidence with building a solid app that works well, is fast, easy to use and looks good.

Again thanks for the reply. Sort of glad that what I planing to do seems OK.

Dan.
 

PG2G

New member
Dec 20, 2010
453
0
0
Visit site
Couldn't you just design your database so user settings like favorites are in a different table than the "items"? That way you could just drop and load the "items" on upgrade and their settings could remain untouched.
 

RogueCode

New member
Apr 16, 2011
76
0
0
Visit site
I was toying with the idea of using some kind of data service to check the web for new data and download it and append it (OTA), but am not confident enough just yet to go down that path. Future applications I do will do that. For now I just want to build up my confidence with building a solid app that works well, is fast, easy to use and looks good.

Yeah - this is where I was heading by asking you how big it was. Because if it was massive cumulative data would be a waste.
 

Wobjoi

New member
Jan 23, 2012
34
0
0
Visit site
Couldn't you just design your database so user settings like favorites are in a different table than the "items"? That way you could just drop and load the "items" on upgrade and their settings could remain untouched.

Yeah, this would be a good option. Actually seems quite obvious as well now that I think about it. Its not to much work for me to change my DB schema to support this method either, so I will probably change what I have done so far to work like this suggested way. All I would have to do is drop the "Info" table and reload it from the xml file and delete the xml file when I'm done. Seems pretty simple.

thanks :)

Its great to have some people to get ideas from. You don't always think of them yourself and when you get this kind of feedback, it's obvious that this is the type of anser I was looking for.
 

Members online

Forum statistics

Threads
322,901
Messages
2,242,866
Members
428,004
Latest member
hetb