Preference items in RealSQLDB ?

I have a few preference items in my project. What is the best way to store them in the RealSQLDatabase ? Or should I use a BIN file for that ?

Not sure if I can get an array in the DB for that ?

You can either store them in a local database or an XML document (such as a .plist).

As far as arrays in a database go, you can either break them down into a table with two indexes (array ID and index ID), or simply join them into comma-delimited format, and break them back apart up retrieval.

Hope this helps. :slight_smile:

Thanks Jason. It makes sense to have a “Prefs” table then and use the “array” proposal above.

I am new to this, so just one more question that you may help me. When I build the RealSQLDB I start with NIL records. It is a simple way to add the first record there ?

In short, should I code something for the first app run ? Where do I store that ? In a file that I should try to read when the app opens ?

First, it sounds like you’re pretty new to databases. I strongly recommend searching for tutorials on SQL databases. SQL, as you may or may not know, is a language in and of itself. Also, look through the SQLite examples that came with Xojo.

Depending on your app, you could look for the database file in either the same directory as your app, or in the SpecialFolder.Preferences. If the file isn’t there, then create it, attach it to the SQLite database object, create your tables, and you’re good to go.

You can read/write to the database throughout the app if that’s useful to you. I’m afraid the tried and true answer for almost every programming situation is, however, “it depends”. :wink:

In fact, it would be better (to get an answer) if you tell us what kind of Preferences you want to save.

Here, I save preferences in a plain text files (I have few to save / few time to do that; with more time I uwould use xml), and other ‘data’ in a Table withing the sqlite file. In fact, I have two special tables (that you may think they hold preferences) and the main Table (the working Table with the data displayes, Edited, Saved or Deleted…

The reasons I add two Tables is because the data I store in them is related to the main Table data display (for one Table) and I wanted to save the data in the other Table withing the sqlite file. I do not recall the name of the Table I set first (that leads me to save data in another table).
Each of there two Tables have a single Record and hold very different data.

This isn’t in a REALSQLDatabase, but it handles preferences: