Wouldn’t it be great to be able to extend the SQLiteDatabase in order to simplify that?
Xojo web browser code#
It also means that you’ll be writing the same code snippet again and again in every new app. What we have just done works, but it means you need to change the database file name, probably for every app you build. Thus, it wouldn’t make much sense to automate this process (but it is certainly doable following the same principles). What about a Web app that you host? That would mean you are in control of the folder/directory you want to use to store the app resources. PDatabase.DatabaseFile = ("EddiesElectronics.sqlite") First, make sure that the Copy File Build Step has the following values in the Inspector Panel: If you’re working on Xojo Cloud, the code is even shorter. PDatabase.DatabaseFile = f.Child("EddiesElectronics.sqlite") Var f As FolderItem = SpecialFolder.Documents Create a SQLiteDatabase instance and try to open database file from If Not ("EddiesElectronics.sqlite").Exists Then if not, copy the database file from Resources bundle/directory Check if our database file already copied on the Documents Sandbox folder PDatabase.DatabaseFile = (name).Child("EddiesElectronics.sqlite")įor an iOS app, the code would be: Var source As FolderItem = SpecialFolder.Resource("EddiesElectronics.sqlite") Create a SQLiteDatabase instance and try to open our database file from
If Not (name).child(source.name).exists Then source.CopyTo((name)) If Not ((name).Exists And (name).IsFolder) Then (name).CreateFolder if not, create it and copy the database file from Resources bundle/directory Check if there is a folder with the App name in special Application Data Also, make sure to add the pDatabase property to the App object in the Navigator: Var source As FolderItem = SpecialFolder.Resource("EddiesElectronics.sqlite") The Application Support folder is a good place for Desktop apps, while the Documents folder is fine for Web and iOS apps.įor example, if our database file is named “EddiesElectronics.sqlite” and our app name is “Xojotest”, then we can add the following code fragment into the Opening Event Handler of a Desktop app.
The best thing to do is to check every time you run the app to see if the database file has already been copied from the app bundle (or folder) into a target folder that doesn’t have an access problem when it is time to use the database.
They are many reasons you shouldn’t do that, notably because the database would be open in read/write mode and if you write to that database file inside an application bundle, then you’d be modifying a resource and that would invalidate any certificate signature on your app. You may think that adding a Build Step is all you need to do, because if the database file is already copied to a well known path then you only need to provide that path as the DatabaseFile property on a new SQLiteDatabase instance. Copying the Database File to a “Working” Folder We have already implemented Department-of-Defense-level security measures, automatic backups and more, letting you focus on developing your app and leaving the hard stuff to us.2. Using our Xojo Cloud, which is shipping this summer, you simply click one button and your web browser opens and your app is launched. Previously, deploying a web application has been a showstopper for many developers because it requires having expert level knowledge of configuring a server, installing your own security measures, creating backups, and more. Using Xojo, you drag and drop your user interface and use our straightforward language to program your app’s functionality. You have to be an expert in a number of web technologies – like HTML, CSS, PHP, JavaScript, AJAX, the list goes on. You see, traditionally creating web applications has been a painful process. CHESTER: What is something exciting or innovative that your company is doing?ĭana: We are working on some really exciting stuff.