How to Store Dynamic Data in App
Hello
I am new to programming applications(win32) & I am trying to learn the best & conventional ways to structure an application.
I have a question about where I should store my "dynamic data" in my application. When I talk about dynamic data I dont mean like "int a = new int;". I will give an example of what I am talking about...
I have an application that reads/searches a folder(dir) of music files & creates a random playlist, the apllication stores the most recently searched directory(folder) path in a string, eg 'string lastPath= "C:/users/Jake/Desktop/Music" ', so that this string will be loaded into an editbox the next time the application is loaded. And when a different directory is searched, that directory now becomes the contents of the string lastPath. So that variable is constantly being updated everytime the application is used.
- What would I call this kind of data? Dynamic data, isn't right is it?
- What is the best &/or conventional way to store & update this data(string lastPath)?
Would it be: (& which would be best for win32 apps or for other apps)
- SQL file
- Text File
- In binary in a text file
- In the actual cpp file & then each time I run the app I update my own source code (is this possible?)
I think "persistent" data is a better name. It's data that "persists" between runs of your program.
You've got a lot of options:
You've got a lot of options:
- Store it in a file under CSIDL_APPDATA
- In the registry
- In an SQL database (though this definitely sounds like overkill for what you want here)
If you need to store lots of data and do quick look ups (like for example if you store a complete playlist with thousands of songs) then you can combine Codeka's suggestion 1 and 3 by using SQLite. It gives you a fairly complete SQL database in a single file.
As an user I much prefer apps that writes a config file to APPDATA over using the registry. The registry quickly becomes cluttered and makes Windows dog slow since it's almost impossible to clean up probably. With APPDATA I can always just delete the files.
Btw. I just learned today that from Vista forwards it's not CSIDL_* anymore, but FOLDERID through the Known Folders API.
As an user I much prefer apps that writes a config file to APPDATA over using the registry. The registry quickly becomes cluttered and makes Windows dog slow since it's almost impossible to clean up probably. With APPDATA I can always just delete the files.
Btw. I just learned today that from Vista forwards it's not CSIDL_* anymore, but FOLDERID through the Known Folders API.
Quote:Original post by Promethium
If you need to store lots of data and do quick look ups (like for example if you store a complete playlist with thousands of songs) then you can combine Codeka's suggestion 1 and 3 by using SQLite. It gives you a fairly complete SQL database in a single file.
As an user I much prefer apps that writes a config file to APPDATA over using the registry. The registry quickly becomes cluttered and makes Windows dog slow since it's almost impossible to clean up probably. With APPDATA I can always just delete the files.
Btw. I just learned today that from Vista forwards it's not CSIDL_* anymore, but FOLDERID through the Known Folders API.
Thanks guys :D
I think I'll take your advice & try APPDATA. Good advice on registry vs. APPDATA, its nice to learn these things :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement