Recently, Thomas Gruber raised the question about when databases get overwritten on an iOS 6 device. We looked into and found it was indeed a good question. First, there were some bugs in the SQLImport() function that needed to be fixed. Second, we found that a couple more options were needed to make it really useful. Make sure you are running at least version 2.6.0.2 of App Studio to get these features.
We made changes to the 4th parameter of SQLImport():
SQLImport(Json, DB, callback, overwrite)
The fourth parameter, overwrite, now has 4 possible values. It can be used in the function and in the manifest.
NSB.overwriteAlways | overwrite the existing database (default). |
NSB.overwriteNever | only write out database if it does not exist yet. |
NSB.overwriteIfVersionDifferent | overwrite if the version number of the database has changed. |
NSB.overwriteIfVersionSame | overwrite if the version number of the database is the same. |
The old True/False options for the overwrite parameter will continue to work as before.
Also, SQLImport now returns a string with the status of the callback function.
Here are some use cases. (You’re welcome to rerun the tests on other devices or versions of the OS – let me know if you get different results!)
Continue reading “When do databases get overwritten?”