https://kotlinlang.org logo
Title
t

Tim McCormack

04/04/2023, 9:50 PM
I have a question that's not so much about Compose as about desktop applications... how do you know where to store files for the user? Is there any standard for that, or does everyone just have to reinvent that particular wheel for their own application?
a

Adam Brown

04/05/2023, 3:26 AM
since you have the JVM, you can query for the user's home directory as such:
System.getProperty("user.home")
m

mikehearn

04/05/2023, 11:08 AM
It depends on what type of files they are (preferences, user generated data, volatile caches etc).
t

Tim McCormack

04/05/2023, 11:23 PM
I was mostly thinking of user-generated data—journal entries, in this case—but really any of it. (Except for window settings, which I think are managed by the desktop environment or the GUI toolkit.)
That library looks great!
m

mikehearn

04/06/2023, 12:06 PM
In that case if you don't have an explicit save process, just create a directory in the user's $HOME or %USERHOME% directory and let them change the path if they want to. Don't stick user generated data in hidden locations as otherwise it might not get backed up, and some users will want to move those files to a cloud drive.
t

Tim McCormack

04/06/2023, 3:53 PM
What I'm struggling with is that I don't want my user's first experience of the application to be "here, make an annoying and arbitrary decision about file storage". But obviously I do want to empower them to make usable backups, etc.
Currently I ask them to pick a location, but I prefill the dialog box with something that looks plausible. Maybe I could suggest multiple?
~/thing
,
~/documents/thing
,
~/.local/[...]/thing
, pick-your-own.
(and then I have to store a pointer to the chosen location in
.local
or whatever)
I feel like most applications don't ask this question at all.