put highscore into url("file:"&specialFolderPath("cache")&"/highscore")
, which works for me.
But is this method "clean" and are there any conventions about this topic? And where exactly is this file saved (i couldn't find it on my phone)?
Another problem is that I cannot save array variables in files. Something like
put your highscore field or whatever in a variable like tHS
then save this variable to a textfile
put tHS into URL ( "file:" & specialFolderPath("Documents") & "/highscore.txt" )
then read out again
put specialFolderPath("Documents") & "/highscore.txt" into tWhatwasit
if there is a file tWhatwasit then
put url("file:" & ttWhatwasit) into toHthis
answer toHthis
arrays are binary data, so use the arrayEncode/arrayDecode to save and retrieve array data in text format:
...
put 10 into stats["highscore"]
## Store array in TXT format:
put arrayEncode(stats) into url("file:" & specialFolderPath("documents") & "/highscore")
...
## Read into variable again:
put url("file:" & specialFolderPath("documents") & "/highscore") into tStats
put arrayDecode(stats) tStats
...
Hint:
For persistent data use specialfolderpath("documents")!
Thank you Klaus for your reply.
Obviously, arrayEncode was the function I was looking for.
But is the data stored into specialFolderPath("cache") not persistent?
And can data stored into "documents" be edited easily by others?
DolphinTech wrote: Mon Jan 15, 2018 6:58 pmBut is the data stored into specialFolderPath("cache") not persistent?
it is, but that folder is not being backed up by iTunes, if that is important for you.
DolphinTech wrote: Mon Jan 15, 2018 6:58 pmAnd can data stored into "documents" be edited easily by others?
Everyone who has access to the device may be able to edit the data.
So maybe use encrypt() to encrypt your data before saving, if you have really sensitive data.
The cache folder is not permanent. Data will remain until the OS does housekeeping, or the user clears the cache to regain disk space. You can't rely on those files being there, the cache is meant for temporary data. The documents folder is permanent and never cleared until the user uninstalls the app.
Both the cache and documents folders are stored inside the app sandbox and cannot be accessed normally. Those files are not displayed by a file manager and cannot be seen or edited by users. The exception is if the device has been rooted. If so, all files are available. But most users do not have rooted phones so the documents folder is as secure as it gets.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com