Loading database in SpecialFolder

I did put a sqlite file in the copyfile build step of my IOS app and I want to copy it to the app document special folder. The sqlite file is located in the same folder than the application source.

Here is my code in the open event of my application:

[code] dim fichier As text
Dim dbFile As FolderItem

fichier = “v.sqlite”
dbFile = SpecialFolder.GetResource(fichier)

If Not SpecialFolder.Documents.Child(fichier).Exists Then
Dim dest As FolderItem = SpecialFolder.Documents.Child(fichier)
dbFile.CopyTo(dest)
End If
[/code]

The line dbFile = SpecialFolder.GetResource(fichier) cause an Exception As xojo.core.InvalidArgumentException, reason v.sqlite not found.

I just don’t understand…
OSX 10.10.3
Xojo 2015 R2.1

Your code is fine. How is the Copy Files Build Step set up?

You’ll need to make sure the Destination property for the Build Step says “Resources Folder”. And you’ll need to put the Build Step on the iOS icon in the Navigator Build Settings section, between Build and Sign.

It works now. Thank you.

@Paul Lefebvre

I just got Attempt to write a readonly db, I copied it with CopyFiles in build set to the Resources folder, then I saw elsewhere here that that was the reason. So I created an additional CopyFiles and changed destination to App Parent Folder.

Do I need to do something in the app or what should the destination be?

This should explain what you need to do:

Copying Files to Device