Retrieving the Parent and Child Nodes of a Preference Node
In this section, we are going to retrieve the Parent and Child nodes of a Preference Node. You can see in the given example that we have used Preferences.userNodeForPackage(java.lang.String.class) to get the Preference node. After that the method prefs.parent() returns the parent node. We are using the method prefs.childrenNames() in order to get the child node. If there is no child node corresponding to the Preference node, it will return null.
Here is the code of RetrievingParentAndChild.java
Output will be displayed as: