Storing Data on Desktop Apps
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 50
- Joined: Sun Jun 30, 2013 1:43 am
- Contact:
Storing Data on Desktop Apps
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?
-
- Posts: 253
- Joined: Wed Aug 19, 2015 4:29 pm
Re: Storing Data on Desktop Apps
You can write to folders other than documents or preferences using:
This path can be just about anywhere the user has permission to write.
Code: Select all
put myData into URL ("binfile:"&thePathToFile)
Re: Storing Data on Desktop Apps
So can you put "G:\data\mine" into "thePathToFile"and have it work?
B
B
-
- Posts: 50
- Joined: Sun Jun 30, 2013 1:43 am
- Contact:
Re: Storing Data on Desktop Apps
Thanks for getting back to me ClipArtGuy
Thanks in advance.
Tom
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?ClipArtGuy wrote:This path can be just about anywhere the user has permission to write.
Thanks in advance.
Tom
-
- Posts: 253
- Joined: Wed Aug 19, 2015 4:29 pm
Re: Storing Data on Desktop Apps
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.
-
- Posts: 253
- Joined: Wed Aug 19, 2015 4:29 pm
Re: Storing Data on Desktop Apps
The answer to your first question is -yes, many. (refer to my initial response)physicsclassroom wrote:Thanks for getting back to me ClipArtGuy
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?ClipArtGuy wrote:This path can be just about anywhere the user has permission to write.
Thanks in advance.
Tom
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/"
-
- Posts: 50
- Joined: Sun Jun 30, 2013 1:43 am
- Contact:
Re: Storing Data on Desktop Apps
That will be helpful. Thanks. Two questions though: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/"
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?
-
- Posts: 253
- Joined: Wed Aug 19, 2015 4:29 pm
Re: Storing Data on Desktop Apps
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.
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
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 50
- Joined: Sun Jun 30, 2013 1:43 am
- Contact:
Re: Storing Data on Desktop Apps
Thanks Jacque,
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?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.
Re: Storing Data on Desktop Apps
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.
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Storing Data on Desktop Apps
Hi all,
this is my function to get the appropriate "preferences/user data" folder on each platform:
And yes, creating a subfolder here for your application a good idea!
Best
Klaus
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

Best
Klaus
Re: Storing Data on Desktop Apps
I sugget you to read this: http://livecode.wikia.com/wiki/Saving_files_on_Android
and this: http://livecode.wikia.com/wiki/SpecialFolderPath
and this: http://livecode.wikia.com/wiki/SpecialFolderPath
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w