Thanks again to Ulrich B and Emile S for helping me identifying errors while working through the Introduction to Programming with Xojo Book. I have managed to work right through to Databases and got many errors but with their tips I fixed them all and the Address Book finally worked.
My only confusion with the database example was - Where is my database file saved and what is its name?
The App uses the following Method (CreateDatabase) to create one if not present
MyDBFile = SpecialFolder.ApplicationData.Child(“Ch12”)
If MyDBFile <> Nil Then
MyDatabase = New SQLiteDatabase
MyDatabase.DatabaseFile = MyDBFile
If MyDatabase.CreateDatabaseFile() Then
If MyDatabase.Connect() Then
SpecialFolder.ApplicationData points to different locations depending on what OS your app runs on.
Check http://documentation.xojo.com/index.php/SpecialFolder and look for ApplicationData in the list
Thanks Albin, Found it.
The link helped to further understand other paths.
I am using Windows 8.1
The location it was saved maybe for security purposes, If I am not concerned on security, is it possible to save it on the default folder the project is saved without being specific as the app may need to move around to different locations since it can be portable?
If it can how to code it?
Sure! To point a FolderItem to the location of the app itself you can use GetFolderItem without passing it anything.
MyDBFile = GetFolderItem("").Child("Ch12")
Realize that this might not work at runtime on all OS’s. In Windows, for example, this folder is NOT writeable. It is recommended that you use SpecialFolder.ApplicationData and if you want it to be used by multiple users SpecialFolder.SharedApplicationData.
When I used MyDBFile = GetFolderItem("").Child(“Ch12”) I realised it was temporally created during run time.
I found this in the library that worked.
MyDBFile = SpecialFolder.CurrentWorkingDirectory.Child(“Ch12”)
Hope it does not give me any problems I am not aware.
If you’re planning on a Windows version you can forget that. Use specialfolder.applicationdata - that does work xPlat.
No, this is not temporary: it is overwriten at each run since you do not check if the folder already exists or not.
In fact, I do not really know what it can do
What happens when I create a new folder when one already exists ?
To be deleted, a folder have to be empty: that is why I asked the question above
Best I use the example used in the eBook before I get any further confused.
MyDBFile = SpecialFolder.ApplicationData.Child(“Ch12”).
Thanks all for your feedback.