Removing a Preference from a Preference Node - Java Native OS

Java examples for Native OS:Preference

Description

Removing a Preference from a Preference Node

Demo Code

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;

public class Main {
  public static void m() {
    // Get the user preference node for java.lang
    Preferences prefs = Preferences.userNodeForPackage(String.class);

    // Remove a preference in the node
    final String PREF_NAME = "name_of_preference";
    prefs.remove(PREF_NAME);//  w w  w  .j a v  a 2 s  .  co m

    // Remove all preferences in the node
    try {
      prefs.clear();
    } catch (BackingStoreException e) {
    }
  }
}

Related Tutorials