Mega Code Archive

 
Categories / Java Tutorial / Development
 

Removing a Preference Node

import java.util.prefs.Preferences; public class Main {   public static void main(String[] argv) throws Exception {     boolean exists = Preferences.userRoot().nodeExists("/yourValue"); // false     if (!exists) {       Preferences prefs = Preferences.userRoot().node("/yourValue");       prefs.removeNode();       // prefs.removeNode();     }     Preferences prefs = Preferences.userRoot().node("/yourValue/child");     exists = Preferences.userRoot().nodeExists("/yourValue"); // true     exists = Preferences.userRoot().nodeExists("/yourValue/child"); // true     Preferences.userRoot().node("/yourValue").removeNode();     exists = Preferences.userRoot().nodeExists("/yourValue"); // false     exists = Preferences.userRoot().nodeExists("/yourValue/child"); // false   } }