title: Java util Preferences constructors
body: <p>I'm trying to understand how the different constructors for <code>java.util.prefs.Preferences</code> works, and not sure which ones to use under different scenarios.</p>
  <p>For one, <strong>does <code>Preferences</code> persist preferences/properties to file?</strong> In other words, can I use this class to store preferences across runs of my application, or is everything held in-memory?</p>
  <p>As far as constructors, there's only a few ways to instantiate a <code>Preferences</code>:</p>
  <pre><code>Preferences p = new Preferences();
  Preferences p = Preferences.userNodeForPackage(this.getClass());
  Preferences p = Preferences.userRoot();
  </code></pre>
  <p>The <a href="http://docs.oracle.com/javase/6/docs/api/java/util/prefs/Preferences.html" rel="nofollow noreferrer">API docs</a> for those constructors are as-follows (respectively):</p>
  <blockquote>
  <p>Sole constructor.</p>
  <p>Returns the preference node from the calling user's preference tree that is associated (by convention) with the specified class's package.</p>
  <p>Returns the root preference node for the calling user.</p>
  </blockquote>
  <p>So I guess I'm confused about the relationship between different <code>Preferences</code> instances, Java classes (<code>useNodeForPackage(Class&lt;?&gt;)</code> ???) and the end user. So I ask: <strong>what does each constructor/factory method do differently than the other, and when to use each?</strong></p>
  <p>Thanks in advance!</p>