Page 1 of 1

Storing Data on Desktop Apps

Posted: Sun Aug 21, 2016 7:02 pm
by physicsclassroom
I'm looking for advice on where to store data (preferences, progress data, etc.) on a Desktop app that I'm building. I want to make sure I'm doing this correctly. It looks like I really only have two choices - documents folder or preferences folder. On the mobile version of the same app, I stored the data in the documents folder. On a desktop app, it doesn't seem that the documents folder would be the best choice. A user looks in their documents folder quite regularly and might see a file they don't recognize and trash the file. Are there any best practices for the location for stored data or pros and cons of each possibility? I will be using both a stack and some text files for the storage containers. It is an educational app that tracks student progress and so some of the information must be kept very secure. And ideas?

Re: Storing Data on Desktop Apps

Posted: Sun Aug 21, 2016 8:07 pm
by ClipArtGuy
You can write to folders other than documents or preferences using:

Code: Select all

put myData into URL ("binfile:"&thePathToFile)
This path can be just about anywhere the user has permission to write.

Re: Storing Data on Desktop Apps

Posted: Sun Aug 21, 2016 8:29 pm
by bern333
So can you put "G:\data\mine" into "thePathToFile"and have it work?

B

Re: Storing Data on Desktop Apps

Posted: Sun Aug 21, 2016 8:50 pm
by physicsclassroom
Thanks for getting back to me ClipArtGuy
ClipArtGuy wrote:This path can be just about anywhere the user has permission to write.
My real question is not so much HOW to write, but WHERE to write. Are there more than two places to write to on Desktop - Preferences and Desktop? And what ate the pros and cons to one location over the other?

Thanks in advance.

Tom

Re: Storing Data on Desktop Apps

Posted: Sun Aug 21, 2016 10:12 pm
by ClipArtGuy
bern333 wrote:So can you put "G:\data\mine" into "thePathToFile"and have it work?

B

I think you would need to specify a file as well -- put "G:\data\mine\output.txt" into thePathToFile.

Re: Storing Data on Desktop Apps

Posted: Sun Aug 21, 2016 10:20 pm
by ClipArtGuy
physicsclassroom wrote:Thanks for getting back to me ClipArtGuy
ClipArtGuy wrote:This path can be just about anywhere the user has permission to write.
My real question is not so much HOW to write, but WHERE to write. Are there more than two places to write to on Desktop - Preferences and Desktop? And what ate the pros and cons to one location over the other?

Thanks in advance.

Tom
The answer to your first question is -yes, many. (refer to my initial response)

For the second, I usually save any external files relative to my executable. If my executable lives at "/home/clipartguy/MyApp/MyAppsExecutable" I might keep my preferences in "/home/clipartguy/MyApp/Preferences/"

Re: Storing Data on Desktop Apps

Posted: Mon Aug 22, 2016 3:53 am
by physicsclassroom
ClipArtGuy wrote:For the second, I usually save any external files relative to my executable. If my executable lives at "/home/clipartguy/MyApp/MyAppsExecutable" I might keep my preferences in "/home/clipartguy/MyApp/Preferences/"
That will be helpful. Thanks. Two questions though:
1) Do I need to create the folder titled Preferences and then save files to it or does the Preference file already exist?
2) Can I save stacks in the Preferences folder or is it limited to just text files?

Re: Storing Data on Desktop Apps

Posted: Mon Aug 22, 2016 4:01 pm
by ClipArtGuy
1 - You can either create folders during development, or through script using the "create folder" command.

2 - To my knowledge you can save just about any type of data this way , although if you are using stacks, the save command might be a better bet.

Re: Storing Data on Desktop Apps

Posted: Mon Aug 22, 2016 6:39 pm
by jacque
Which OS? On Mac the only approved location is in the Application Support folder which is specialFolderPath("asup"). You can still store data in Preferences too, but Apple has deprecated that and suggests you avoid it for future compatibility. Windows has a similar approved location but it escapes me at the moment.

Re: Storing Data on Desktop Apps

Posted: Wed Aug 24, 2016 12:50 pm
by physicsclassroom
Thanks Jacque,
jacque wrote:Which OS? On Mac the only approved location is in the Application Support folder which is specialFolderPath("asup"). You can still store data in Preferences too, but Apple has deprecated that and suggests you avoid it for future compatibility. Windows has a similar approved location but it escapes me at the moment.
I am developing for a Mac at the moment. My hope was to use specialFolderPath("Documents") as it seems to be permitted but was wondering what the pros and cons were for saving to documents as opposed to saving to preferences or any other location?

Re: Storing Data on Desktop Apps

Posted: Wed Aug 24, 2016 4:43 pm
by jacque
The documents folder is permitted (it's writable) but only approved for files the user creates. Some apps ignore that but Apple doesn't like it. If you are saving user-generated data then it's appropriate. If you're saving preferences or other data the app needs but the user never interacts with directly, the app support folder is where those files should go.

The idea is not to clutter the documents folder with files the user will never need to open. In either location you should create a folder named for the app and put the files in there rather than loose in the main folder.

Re: Storing Data on Desktop Apps

Posted: Thu Aug 25, 2016 11:26 am
by Klaus
Hi all,

this is my function to get the appropriate "preferences/user data" folder on each platform:

Code: Select all

function mkprefsfolder
  switch the platform
  case "MacOS"

    ## Application support
    put specialFolderPath("asup") into spfp
    break
  case "Win32"

    ## Windows >= 2000
    if the systemversion contains "NT" then
      put specialFolderPath(35) into spfp
      ### For all users!
      ### specialfolderpath(26) = for the current user only!
    else

     ## Win95 - XP
      put specialfolderpath("system") into spfp
    end if
    break
  default

    ## *nix
    put $HOME into spfp
    break
  end switch
  return spfp
end mkprefsfolder
And yes, creating a subfolder here for your application a good idea! :D


Best

Klaus

Re: Storing Data on Desktop Apps

Posted: Wed Aug 31, 2016 11:18 am
by MaxV