There are many applications which require certain types of configuration data for their processing. The configuration data often stored in property files and properties has to read/write into this property files ,so there is always an overhead of managing these property files.
The Preferences API introduced in J2SE 1.4 allows applications to store and manipulate user and system configuration data. This data will be stored persistently in an implementation-dependent backup store. Typical implementations of these storage includes flat files, OS registries, directory servers and SQL DBs .
Preferences API stores preference values as persistent key/value pairs called nodes. There will be many nodes in a tree. There are commonly two types of trees , one used for user preferences and the other for system preferences. There will be separate preference tree for each user. But only one system preference tree for the system will be shared by all users.

Preferences prefs =Preferences.userNodeForPackage(mypackage.MyClass.class);

This Preferences object is used to read and write data. The get() and put() methods are used to insert and retrieve values from the node. The data can be any of following type.
  • int (e.g getInt(String key, int default value))
  • float (e.g void putFloat(String key, float value))
  • long
  • double
  • boolean
  • byte
  • String
  • If you want to clear the values from memory, use the following method
    try {
    userPrefs.clear();
    // Delete the preference settings for the value
    userPrefs.remove(“key”);
    }
    catch (BackingStoreException e)

    {
    e.printStackTrace();
    }
    You can also implement a listener to know the changes in the preferences,PreferenceChangeListener is used for it.

    public void preferenceChange(PreferenceChangeEvent e)
    {
    //implements here
    }

    The Preferences API permits the user to import/export preference data in XML format. The corresponding DTD is found as part of the javadocs of the java.util.prefs.Preferences class. The methods used for importing and exporting the XML are
    importPreferences(InputStream is)
    This method imports all of the preferences on the XML document into the specified input stream.
    exportNode(OutputStream os)
    This method produce output stream of XML document representing all of the preferences contained in this node ,but not its descendants.
    So where is the data is actually stored ,when we are using preference API? ,the answer reckons on the platform .The static methods in preference API that returns a Preferences object depend on a factory( some concrete implementation of the java.util.prefs.PreferencesFactory interface) The name of this factory class will be specified by java.util.prefs.PreferencesFactory system property.In linux all the data are stored in files on the file system. In windows the preference data stored in the Windows Registry (Specifically, HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs and user preferences are stored under HKEY_CURRENT_USER\Software\JavaSoft\Prefs).
    When comparing with Property files, the Preferences API provides a robust and easy mechanism for organizing the data . It is easy to to group data hierarchically in preference API. Property files are platform dependent ,more specifically on the file system, which may not exist on every platform with a Java VM. Using java.util.prefs.PreferencesFactory, we can store the data using whatever mechanisms that are appropriate for the current platform.