My OSX Cocoa application uses SQLite to manage data. When initializing, I need to specify where the database file will be stored.
What is the standard way of handling this?
This database file is required to run (the app will create it if it doesn't exist), and the data should be persisted for ever, even after software updates if possible.
Where should I store it? Application folder? Support Files?
Thanks
There is no "standard place" for a sqlite database. The file's location is specified to the library, and may be in your home directory, in the invoking program's folder, or any other place. If it helps, sqlite databases are, by convention, named with a . db file extension.
SQLite is included in macOS and Mac OS X by default. It is located in the /usr/bin directory and called sqlite3. Using SQLite, users can create file-based databases that can be transported across machines, platforms, etc.
If you are using Linux or a Mac, open a terminal window instead a command prompt. Open a command prompt (cmd.exe) and 'cd' to the folder location of the SQL_SAFI. sqlite database file. run the command 'sqlite3' This should open the SQLite shell and present a screen similar to that below.
SQLite is an offline database that is locally stored in the user's device and we do not have to create any connection to connect to this database.
The convention is to store it in the Application Support folder. i.e. in ~/Library/Application Support/*YourAppName*/database.db
You can find the Application Support that you're searching with
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With