App uses the 'old' database after downloaded the 'new' one

mc73

Well-Known Member
Licensed User
Longtime User
Hello,

I have an activity which downloads a new version of my database. When finished downloaded (and I can assure you that the new file is properly copied - I see its contents there, with another app), I close my app (just with activity.finish). User is supposed to reload the app, but then I realize that my app is still using the 'old' database. This thing is corrected, if Ι set my device to clear all its RAM contents. Then, we can read the new db. Now, I can understand that the cause of this, is that probably the OS is reading the db from its RAM contents, so I have to tell my clients either to clear RAM or to restart their device. Still, I find it weird. Using all sql.close commands, properly activity.finish to each activity, initializing the db in activity_create (I put a msgbox there, just to be sure that the initialization process, after the db update, is performed) and there it is the 'old' db, sitting in my RAM. Any idea or am I missing something here?
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
What is the order you are doing this in? Are you SQL Closing then Deleting/Copying over the file, then SQL Initializing? Could be the SQL object writes back the file if you delete/copy over then SQL Close. What location is this wrote to? Could be certain locations have file caching on your device too.

Until I fixed a menu in one of my apps I actually had some code that was deleting the db file while the SQL object had it open that was working fine too. Next access read no data and I created the tables again without issue or old data remaining. This was to purge the db quickly when I changed table structure and test creating the new tables and using the data, and if it had cached the old data then I wouldn't have been able to create the new tables or use the new fields...so even when things got out of order it was still working.

Might try a couple things if the above doesn't help- 1. Make sure it really isn't your cursors doing the caching or not closing. 2. Try naming the 2nd file a different name and initializing the SQL object with it (If still cached then it isn't the file or SQL object caching it).
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Dear Roger, thank you for your thorough analysis. Unfortunately, I've checked and rechecked all aspects of the close cursors-sql/delete/copy/reinitialization process, without success. Today I will check some new logs I've created, perhaps there will be some info soon. Thanks again!
 
Upvote 0

timwil

Active Member
Licensed User
Longtime User
How are you downloading the new database?

What I do is clear out the old data and just download the new data and apply to the database
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
How are you downloading the new database?

What I do is clear out the old data and just download the new data and apply to the database
I download the complete database as a file. Storing is perfomed without a problem, I can in parallel watch the new database in another app updated. The cache is the problem. It is ok, as I've already said, my workaround for now, is to notify users to restart the device. After many years dealing with Windows, I think almost everyone is used to perform such tasks :)
 
Upvote 0
Top