Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating directory in Application Support or %appdata%

Tags:

java

directory

I am already familiar with creating files and putting them in "user.home". I'm on Mac, so don't know much about PC's folder, but in my library, there is Application Support. Is there a way to place a directory there and also in PC's %appdata%?

like image 273
Amundeep Singh Avatar asked Jan 09 '12 00:01

Amundeep Singh


People also ask

What is the directory for AppData?

You can view the AppData folder manually by going into your Users folder, which is there in the C drive. In my case, the path is C:\Users\ADMIN .

Where should I put data in Linux?

Any program or package which contains or requires data that doesn't need to be modified should store that data in /usr/share (or /usr/local/share , if installed locally). It is recommended that a subdirectory be used in /usr/share for this purpose. Applications using a single file may use /usr/share/misc .


1 Answers

The AppData folder on Windows is "{user.home}\Local Settings\ApplicationData";

You can get it using this:

    String dataFolder = System.getProperty("user.home") + "\\Local Settings\\ApplicationData";

or by this, but it's only works on Windows because the env variable 'APPDATA' only available under Windows.

    String dataFolder = System.getenv("APPDATA");  

Fore more information, you can check it out How to get local application data folder in Java?

like image 189
donnior Avatar answered Sep 26 '22 23:09

donnior