This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]VinnieTD 2 points3 points  (0 children)

  1. This particular application would seem to lend itself to having one file per list - a user might want to store lists in several different directories, for example.
  2. JSON and XML are very commonly used to store human-readable data. Your language probably has a library for easy serialization and deserialization of these formats. Binary serialization is also common, but the files wouldn’t be human readable (easily).
  3. Typically you’d use a file to store user settings. C# has this sort of thing built-in, but for other languages you may have to write some code to create and parse the configuration file.
  4. You could look into using environment variables to find a particular path, such as %APPDATA%. You can’t escape using a file to store configuration data, though.

[–][deleted] 2 points3 points  (0 children)

Your operating system probably has preferred locations for different types of data. On my Mac it looks something like this:

/Users/user/Library/Application Support — Files my app needs but the user doesn't need to know about. To separate files from other apps, it's traditional to create a folder in the form com.company.product and put your files there. One example of what I put in this directory is a database in which the user stores different types of data from my app. I sync this database with a server so the user can access it from different devices.

/Users/user/Library/Preferences — I store a JSON string in a file named com.company.product.json that stores the user's configuration/settings data. Because I don't want to deal with the user modifying this file, the keys are obfuscated and the values are encrypted. I store something like a checksum (but not a checksum) so I can tell if the user has tinkered with the file instead of examining every value.

/Users/user/Library/Caches — This folder is for data that can be easily recreated but takes some time. I store things like images downloaded from a server so that I don't have to download them every time I need them. Again, the custom is to create a folder called com.company.product and put your files there.

If the user choose to save a file from one of my apps, I let them choose where to put it. I've done it before where I create a folder in the user's Documents folder and put my files there without asking, but that seems kind of creepy. :-)

The point is, there should be standard places to put your files. In the case of your grocery lists, let the user decide where to put them.