Sign in to follow this  
gretty

How to Store Dynamic Data in App

Recommended Posts

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?)

Share this post


Link to post
Share on other sites
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:
  1. Store it in a file under CSIDL_APPDATA
  2. In the registry
  3. In an SQL database (though this definitely sounds like overkill for what you want here)
There's probably more, but I think the simplest solution is just to store it in a text file under CSIDL_APPDATA (that is, "C:\Users\<username>\AppData\Roaming\*").

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this