Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should cross-platform apps keep their data?

I'm building an application that is targeting Windows, Mac and Linux soon. I was wondering where should I keep application data such as settings, etc.

Application's installation folder is the easiest choice, but I think that might be a problem with new Vista security model. Besides, users might want different settings.

Is it C:\Documents and Settings\username\MyApp good for both Vista and XP? Is it /home/username/.MyApp good for Linux and Macs?

Any ideas and/or links to best practices much appreciated.

Thanks!

Juan

like image 544
Juan Delgado Avatar asked Sep 11 '08 16:09

Juan Delgado


People also ask

How do cross-platform apps work?

In cross-platform app development, a single and a universal app is compatible for running on all platforms. This makes it easier to maintain and deploy code as changes are made. Updates can promptly be synced over all platforms and devices, thus saving time and money.

Which type of the application works on cross-platform?

For example, a cross-platform application may run on Microsoft Windows, Linux, and macOS. Cross-platform software may run on many platforms, or as few as two. Some frameworks for cross-platform development are Codename One, Kivy, Qt, Flutter, NativeScript, Xamarin, Phonegap, Ionic, and React Native.


1 Answers

Each platform has its own API for finding the user's home folder, or documents folder, or preferences folder.

  • Windows: SHGetFolderPath() or SHGetKnownFolderPath()
  • Mac OS X and iPhone OS: NSSearchPathForDirectoriesInDomains()
  • Unix: $HOME environment variable

Don't hardcode specific paths or just tack a prefix and suffix on the user's name. Also, try to follow whatever conventions there are for the platform for naming the files.

like image 67
3 revs Avatar answered Sep 28 '22 08:09

3 revs