Copy/create files for deployment

Hi. I’m looking ahead for when I deploy the project and have a question regarding database files. Based on the example projects, I’ve been able to copy over a db file so the app can run in the simulator.

Using this code:

[code] Dim dbFile As FolderItem
dbFile = SpecialFolder.GetResource(“iOSexam.sqlite”)

If Not SpecialFolder.Documents.Child(“iOSexam.sqlite”).Exists Then
// Only copy the file if it is not already there
Dim dest As FolderItem = SpecialFolder.Documents.Child(“iOSexam.sqlite”)
End If[/code]

I was taking a look at my desktop apps, and see when I copy over the db file, I am checking to see if the file is present. If not, a folder is created, then the file is copied over. Example code below:

[code] Dim sourceDB As FolderItem

sourceDB = app.ExecutableFile.Parent.Parent.Child(“Resources”).Child(“examRDDTR.sqlite”)

If sourceDB <> Nil And sourceDB.Exists Then
// Create destination folder
Dim appData As FolderItem = SpecialFolder.ApplicationData
Dim appFolder As FolderItem = appData.Child(“com.visualveggies.rdpracticeexam”)

// Copy DB to destination

End If[/code]

My question is does this folder creation event need to occur with iOS too or would the first code above put the files in the right place? Does the code from the examples only temporarily copy the files to run in the simulator? In addition to this file, I will also be creating an empty db file for storing some info and don’t want this to be wiped out each time the app closes and a new one created.


The specialFolder folders (documents folder, etc.) are created for your app when it is installed on the device. No action needed on your part. The only time that the folders or your files within those folders would be deleted, is if your app deletes the files or if the user deletes the app from their device.

The files that you place in the folders persist through version updates, launch and quit, etc. Even in the simulator, my written files would stay between launches when debugging my apps.

That’s great! Thank you Scott!