简体   繁体   中英

Where can I store an SQLite database on Windows and OS X?

I'm developing a Qt application that will be distributed on Windows and OS X .

The application makes use of an SQLite database. Where can I keep the database file on both systems for it not to be overridden during application updates?

Note 1 : I already find a similar question about that for OS X . The answer was to keep it in the Application Support using the following command:

NSString * supportDir = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDir‌​ectory, NSUserDomainMask, YES) lastObject];

But I need to do that on Windows too. Should I use this command on Windows too?

Note 2 : I'm using an INI file to store my application settings as follows:

QString path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
QSettings *settings = new QSettings(path+"/Settings.ini", QSettings::IniFormat);

The path variable is C:/Users/user/AppData/Local/MyApplication/ (Windows).

Can I store the database file in the same path?

Thank you.

Does QStandardPaths::AppDataLocation cover your requirements for this?

From the qt documentation :

Returns a directory location where persistent application data can be stored. This is an application-specific directory. To obtain a path to store data to be shared with other applications, use QStandardPaths::GenericDataLocation. The returned path is never empty. On the Windows operating system, this returns the roaming path. This enum value was added in Qt 5.4.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM