IOS database access

If I create a sql lite database and drag it into xojo, Xojo will show the tables and fields, but any attempt to run the app gives a “Can’t find a type with this name”
If I use copyfiles to copy the database to the resources folder, i can access and read the database but not right to it.

I cant seem to find a way to copy a database onto the device and access it read/write.

Is there a way I have missed?

do you need to include it inside the project?
as opposed to checking for existance, and if not exist create it one time with SQL code?

you can include database as a template in your resources. For that don’t drag it to project, but copy with build step.

On first launch of app, copy database template into users documents or preferences folder, so you can write to it.
Stuff in resources folder is read only!

You definitely have to copy it out of the Resources in the bundle before you can write to it. To do so, use SpecialFolder.GetResource to get a FolderItem that you can copy elsewhere:

[code]Dim bundleFile As Folderitem
bundleFile = SpecialFolder.GetResource(“AppDatabase.sqlite”)

Dim newFile As FolderItem = SpecialFolder.Documents.Child(“MyAppDb.sqlite”)
bundleFile.CopyTo(newFile)[/code]

Now you can use newFile to modify the DB.

See this thread in the forums for adding iTunes File Sharing to the plist file of your app.

How to get Database into & out of IOS device?

When I copy my database out of the Resources in the bundle, and into the Documents folder, it’s giving me an IOexception error.

[code] Dim bundleFile As Folderitem
bundleFile = SpecialFolder.GetResource(“vocabDB.sqlite”)

Dim vocabDB As FolderItem = SpecialFolder.Documents.Child(“vocabDB.sqlite”)
bundleFile.CopyTo(vocabDB)[/code]

Can’t figure out what I’m doing (or not doing) that’s causing that.

Do you have a copyfile step to copy the file into your resources folder?

Thanks Wayne. I did indeed have a copyfile step. Just realized my problem was that I was not checking whether the file already existed in that place, and the IOException was that it was trying to copy over an existing file. My bad for wasting your guys bandwidth on a simple question that was clear after a night’s sleep!

Thanks.