I just create an Desktop App in Xojo to create and edit an SQLLite database. For now I want to create an iOS App with Xojo and put the SQLLite database file in the app.
How can I put the database file in the iOS project and access to it from the iOS app ?
I copy the file as you say in app ressource then I use it like this to have read/write access in the app sandbox:
const dbFileName = "mydb.sqlite"
// Get. Ressource
Var source As Xojo.IO.FolderItem = xojo.io.SpecialFolder.GetResource(dbFileName)
// Copy to app sand box
If Not xojo.io.SpecialFolder.Documents.Child(dbFileName).Exists Then
source.CopyTo(xojo.io.SpecialFolder.documents)
End If
Try
// Connect to Database
Var db As New iOSSQLiteDatabase
Var f As FolderItem = xojo.io.SpecialFolder.Documents
db.DatabaseFile = f.Child(dbFileName)
If db.Connect Then
// .....
End If
Catch e As RuntimeException
MessageBox (e.Reason)
End Try