# AbstractPreferences

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#inhconstants)\|[Fields](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#lfields)\|[Protected Ctors](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#proctors)\|[Methods](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#pubmethods)\|[Protected Methods](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#promethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#inhmethods)  

# AbstractPreferences

`
public


abstract
class
AbstractPreferences
`  
`


``

extends `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)`


``


`

|---|---|-------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.util.prefs.Preferences](https://developer.android.com/reference/java/util/prefs/Preferences) ||
|   | ↳ | java.util.prefs.AbstractPreferences |

<br />

*** ** * ** ***

This class provides a skeletal implementation of the[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)class, greatly easing the task of implementing it.

**This class is forPreferencesimplementers only. Normal users of thePreferencesfacility should have no need to consult this documentation. The[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)documentation should suffice.**

Implementors must override the nine abstract service-provider interface (SPI) methods:[getSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getSpi(java.lang.String)),[putSpi(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putSpi(java.lang.String,%20java.lang.String)),[removeSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeSpi(java.lang.String)),[childSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childSpi(java.lang.String)),[removeNodeSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNodeSpi()),[keysSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#keysSpi()),[childrenNamesSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childrenNamesSpi()),[syncSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#syncSpi())and[flushSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#flushSpi()). All of the concrete methods specify precisely how they are implemented atop these SPI methods. The implementor may, at his discretion, override one or more of the concrete methods if the default implementation is unsatisfactory for any reason, such as performance.

The SPI methods fall into three groups concerning exception behavior. ThegetSpimethod should never throw exceptions, but it doesn't really matter, as any exception thrown by this method will be intercepted by[get(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#get(java.lang.String,%20java.lang.String)), which will return the specified default value to the caller. TheremoveNodeSpi, keysSpi, childrenNamesSpi, syncSpiandflushSpimethods are specified to throw[BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException), and the implementation is required to throw this checked exception if it is unable to perform the operation. The exception propagates outward, causing the corresponding API method to fail.

The remaining SPI methods[putSpi(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putSpi(java.lang.String,%20java.lang.String)),[removeSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeSpi(java.lang.String))and[childSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childSpi(java.lang.String))have more complicated exception behavior. They are not specified to throwBackingStoreException, as they can generally obey their contracts even if the backing store is unavailable. This is true because they return no information and their effects are not required to become permanent until a subsequent call to[Preferences.flush()](https://developer.android.com/reference/java/util/prefs/Preferences#flush())or[Preferences.sync()](https://developer.android.com/reference/java/util/prefs/Preferences#sync()). Generally speaking, these SPI methods should not throw exceptions. In some implementations, there may be circumstances under which these calls cannot even enqueue the requested operation for later processing. Even under these circumstances it is generally better to simply ignore the invocation and return, rather than throwing an exception. Under these circumstances, however, all subsequent invocations offlush()andsyncshould returnfalse, as returningtruewould imply that all previous operations had successfully been made permanent.

There is one circumstance under whichputSpi, removeSpi and childSpi*should* throw an exception: if the caller lacks sufficient privileges on the underlying operating system to perform the requested operation. This will, for instance, occur on most systems if a non-privileged user attempts to modify system preferences. (The required privileges will vary from implementation to implementation. On some implementations, they are the right to modify the contents of some directory in the file system; on others they are the right to modify contents of some key in a registry.) Under any of these circumstances, it would generally be undesirable to let the program continue executing as if these operations would become permanent at a later time. While implementations are not required to throw an exception under these circumstances, they are encouraged to do so. A[SecurityException](https://developer.android.com/reference/java/lang/SecurityException)would be appropriate.

Most of the SPI methods require the implementation to read or write information at a preferences node. The implementor should beware of the fact that another VM may have concurrently deleted this node from the backing store. It is the implementation's responsibility to recreate the node if it has been deleted.

Implementation note: In Sun's defaultPreferencesimplementations, the user's identity is inherited from the underlying operating system and does not change for the lifetime of the virtual machine. It is recognized that server-sidePreferencesimplementations may have the user identity change from request to request, implicitly passed toPreferencesmethods via the use of a static[ThreadLocal](https://developer.android.com/reference/java/lang/ThreadLocal)instance. Authors of such implementations are*strongly* encouraged to determine the user at the time preferences are accessed (for example by the[get(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#get(java.lang.String,%20java.lang.String))or[put(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#put(java.lang.String,%20java.lang.String))method) rather than permanently associating a user with eachPreferencesinstance. The latter behavior conflicts with normalPreferencesusage and would lead to great confusion.  
**See also:**

- [Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                   ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                    |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From class[java.util.prefs.Preferences](https://developer.android.com/reference/java/util/prefs/Preferences) |-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [MAX_KEY_LENGTH](https://developer.android.com/reference/java/util/prefs/Preferences#MAX_KEY_LENGTH) Maximum length of string allowed as a key (80 characters).         | | `int` | [MAX_NAME_LENGTH](https://developer.android.com/reference/java/util/prefs/Preferences#MAX_NAME_LENGTH) Maximum length of a node name (80 characters).                   | | `int` | [MAX_VALUE_LENGTH](https://developer.android.com/reference/java/util/prefs/Preferences#MAX_VALUE_LENGTH) Maximum length of string allowed as a value (8192 characters). | |

|                                                                                                                                             ### Fields                                                                                                                                              ||
|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` protected final `[Object](https://developer.android.com/reference/java/lang/Object) | [lock](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#lock) An object whose monitor is used to lock this node.                                                                  |
| ` protected boolean`                                                                  | [newNode](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#newNode) This field should betrueif this node did not exist in the backing store prior to the creation of this object. |

|                                                                                                                                                                                                                             ### Protected constructors                                                                                                                                                                                                                              ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[AbstractPreferences](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#AbstractPreferences(java.util.prefs.AbstractPreferences,%20java.lang.String))`(`[AbstractPreferences](https://developer.android.com/reference/java/util/prefs/AbstractPreferences)` parent, `[String](https://developer.android.com/reference/java/lang/String)` name) ` Creates a preference node with the specified parent and the specified name relative to its parent. |

|                                                                                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                                                                                  ||
|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[absolutePath](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#absolutePath())`() ` Implements theabsolutePathmethod as per the specification in[Preferences.absolutePath()](https://developer.android.com/reference/java/util/prefs/Preferences#absolutePath()).                                                                                                                                                                                             |
| ` void`                                                                               | ` `[addNodeChangeListener](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#addNodeChangeListener(java.util.prefs.NodeChangeListener))`(`[NodeChangeListener](https://developer.android.com/reference/java/util/prefs/NodeChangeListener)` ncl) ` Registers the specified listener to receive*node change events*for this node.                                                                                                                                   |
| ` void`                                                                               | ` `[addPreferenceChangeListener](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener))`(`[PreferenceChangeListener](https://developer.android.com/reference/java/util/prefs/PreferenceChangeListener)` pcl) ` Registers the specified listener to receive*preference change events*for this preference node.                                                                                    |
| ` `[String[]](https://developer.android.com/reference/java/lang/String)               | ` `[childrenNames](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childrenNames())`() ` Implements thechildrenmethod as per the specification in[Preferences.childrenNames()](https://developer.android.com/reference/java/util/prefs/Preferences#childrenNames()).                                                                                                                                                                                             |
| ` void`                                                                               | ` `[clear](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#clear())`() ` Implements theclearmethod as per the specification in[Preferences.clear()](https://developer.android.com/reference/java/util/prefs/Preferences#clear()).                                                                                                                                                                                                                                |
| ` void`                                                                               | ` `[exportNode](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#exportNode(java.io.OutputStream))`(`[OutputStream](https://developer.android.com/reference/java/io/OutputStream)` os) ` Implements theexportNodemethod as per the specification in[Preferences.exportNode(OutputStream)](https://developer.android.com/reference/java/util/prefs/Preferences#exportNode(java.io.OutputStream)).                                                                  |
| ` void`                                                                               | ` `[exportSubtree](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#exportSubtree(java.io.OutputStream))`(`[OutputStream](https://developer.android.com/reference/java/io/OutputStream)` os) ` Implements theexportSubtreemethod as per the specification in[Preferences.exportSubtree(OutputStream)](https://developer.android.com/reference/java/util/prefs/Preferences#exportSubtree(java.io.OutputStream)).                                                   |
| ` void`                                                                               | ` `[flush](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#flush())`() ` Implements theflushmethod as per the specification in[Preferences.flush()](https://developer.android.com/reference/java/util/prefs/Preferences#flush()).                                                                                                                                                                                                                                |
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[get](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#get(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` def) ` Implements thegetmethod as per the specification in[Preferences.get(String,String)](https://developer.android.com/reference/java/util/prefs/Preferences#get(java.lang.String,%20java.lang.String)).   |
| ` boolean`                                                                            | ` `[getBoolean](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getBoolean(java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` key, boolean def) ` Implements thegetBooleanmethod as per the specification in[Preferences.getBoolean(String,boolean)](https://developer.android.com/reference/java/util/prefs/Preferences#getBoolean(java.lang.String,%20boolean)).                                              |
| ` byte[]`                                                                             | ` `[getByteArray](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getByteArray(java.lang.String,%20byte[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, byte[] def) ` Implements thegetByteArraymethod as per the specification in[Preferences.getByteArray(String,byte[])](https://developer.android.com/reference/java/util/prefs/Preferences#getByteArray(java.lang.String,%20byte[])).                                        |
| ` double`                                                                             | ` `[getDouble](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getDouble(java.lang.String,%20double))`(`[String](https://developer.android.com/reference/java/lang/String)` key, double def) ` Implements thegetDoublemethod as per the specification in[Preferences.getDouble(String,double)](https://developer.android.com/reference/java/util/prefs/Preferences#getDouble(java.lang.String,%20double)).                                                       |
| ` float`                                                                              | ` `[getFloat](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getFloat(java.lang.String,%20float))`(`[String](https://developer.android.com/reference/java/lang/String)` key, float def) ` Implements thegetFloatmethod as per the specification in[Preferences.getFloat(String,float)](https://developer.android.com/reference/java/util/prefs/Preferences#getFloat(java.lang.String,%20float)).                                                                |
| ` int`                                                                                | ` `[getInt](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getInt(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` key, int def) ` Implements thegetIntmethod as per the specification in[Preferences.getInt(String,int)](https://developer.android.com/reference/java/util/prefs/Preferences#getInt(java.lang.String,%20int)).                                                                                  |
| ` long`                                                                               | ` `[getLong](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getLong(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` key, long def) ` Implements thegetLongmethod as per the specification in[Preferences.getLong(String,long)](https://developer.android.com/reference/java/util/prefs/Preferences#getLong(java.lang.String,%20long)).                                                                         |
| ` boolean`                                                                            | ` `[isUserNode](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#isUserNode())`() ` Implements theisUserNodemethod as per the specification in[Preferences.isUserNode()](https://developer.android.com/reference/java/util/prefs/Preferences#isUserNode()).                                                                                                                                                                                                       |
| ` `[String[]](https://developer.android.com/reference/java/lang/String)               | ` `[keys](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#keys())`() ` Implements thekeysmethod as per the specification in[Preferences.keys()](https://developer.android.com/reference/java/util/prefs/Preferences#keys()).                                                                                                                                                                                                                                     |
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[name](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#name())`() ` Implements thenamemethod as per the specification in[Preferences.name()](https://developer.android.com/reference/java/util/prefs/Preferences#name()).                                                                                                                                                                                                                                     |
| ` `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences) | ` `[node](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#node(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` path) ` Implements thenodemethod as per the specification in[Preferences.node(String)](https://developer.android.com/reference/java/util/prefs/Preferences#node(java.lang.String)).                                                                                                                      |
| ` boolean`                                                                            | ` `[nodeExists](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#nodeExists(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` path) ` Implements thenodeExistsmethod as per the specification in[Preferences.nodeExists(String)](https://developer.android.com/reference/java/util/prefs/Preferences#nodeExists(java.lang.String)).                                                                                        |
| ` `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences) | ` `[parent](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#parent())`() ` Implements theparentmethod as per the specification in[Preferences.parent()](https://developer.android.com/reference/java/util/prefs/Preferences#parent()).                                                                                                                                                                                                                           |
| ` void`                                                                               | ` `[put](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#put(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Implements theputmethod as per the specification in[Preferences.put(String,String)](https://developer.android.com/reference/java/util/prefs/Preferences#put(java.lang.String,%20java.lang.String)). |
| ` void`                                                                               | ` `[putBoolean](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putBoolean(java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` key, boolean value) ` Implements theputBooleanmethod as per the specification in[Preferences.putBoolean(String,boolean)](https://developer.android.com/reference/java/util/prefs/Preferences#putBoolean(java.lang.String,%20boolean)).                                            |
| ` void`                                                                               | ` `[putByteArray](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putByteArray(java.lang.String,%20byte[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, byte[] value) ` Implements theputByteArraymethod as per the specification in[Preferences.putByteArray(String,byte[])](https://developer.android.com/reference/java/util/prefs/Preferences#putByteArray(java.lang.String,%20byte[])).                                      |
| ` void`                                                                               | ` `[putDouble](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putDouble(java.lang.String,%20double))`(`[String](https://developer.android.com/reference/java/lang/String)` key, double value) ` Implements theputDoublemethod as per the specification in[Preferences.putDouble(String,double)](https://developer.android.com/reference/java/util/prefs/Preferences#putDouble(java.lang.String,%20double)).                                                     |
| ` void`                                                                               | ` `[putFloat](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putFloat(java.lang.String,%20float))`(`[String](https://developer.android.com/reference/java/lang/String)` key, float value) ` Implements theputFloatmethod as per the specification in[Preferences.putFloat(String,float)](https://developer.android.com/reference/java/util/prefs/Preferences#putFloat(java.lang.String,%20float)).                                                              |
| ` void`                                                                               | ` `[putInt](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putInt(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` key, int value) ` Implements theputIntmethod as per the specification in[Preferences.putInt(String,int)](https://developer.android.com/reference/java/util/prefs/Preferences#putInt(java.lang.String,%20int)).                                                                                |
| ` void`                                                                               | ` `[putLong](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putLong(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` key, long value) ` Implements theputLongmethod as per the specification in[Preferences.putLong(String,long)](https://developer.android.com/reference/java/util/prefs/Preferences#putLong(java.lang.String,%20long)).                                                                       |
| ` void`                                                                               | ` `[remove](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#remove(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Implements theremove(String)method as per the specification in[Preferences.remove(String)](https://developer.android.com/reference/java/util/prefs/Preferences#remove(java.lang.String)).                                                                                                     |
| ` void`                                                                               | ` `[removeNode](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())`() ` Implements theremoveNode()method as per the specification in[Preferences.removeNode()](https://developer.android.com/reference/java/util/prefs/Preferences#removeNode()).                                                                                                                                                                                                     |
| ` void`                                                                               | ` `[removeNodeChangeListener](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNodeChangeListener(java.util.prefs.NodeChangeListener))`(`[NodeChangeListener](https://developer.android.com/reference/java/util/prefs/NodeChangeListener)` ncl) ` Removes the specifiedNodeChangeListener, so it no longer receives change events.                                                                                                                          |
| ` void`                                                                               | ` `[removePreferenceChangeListener](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener))`(`[PreferenceChangeListener](https://developer.android.com/reference/java/util/prefs/PreferenceChangeListener)` pcl) ` Removes the specified preference change listener, so it no longer receives preference change events.                                                                        |
| ` void`                                                                               | ` `[sync](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#sync())`() ` Implements thesyncmethod as per the specification in[Preferences.sync()](https://developer.android.com/reference/java/util/prefs/Preferences#sync()).                                                                                                                                                                                                                                     |
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[toString](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#toString())`() ` Returns the absolute path name of this preferences node.                                                                                                                                                                                                                                                                                                                          |

|                                                                                                                                                                                                                                      ### Protected methods                                                                                                                                                                                                                                      ||
|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final `[AbstractPreferences[]](https://developer.android.com/reference/java/util/prefs/AbstractPreferences)  | ` `[cachedChildren](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#cachedChildren())`() ` Returns all known unremoved children of this node.                                                                                                                                                                                                       |
| ` abstract `[AbstractPreferences](https://developer.android.com/reference/java/util/prefs/AbstractPreferences) | ` `[childSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childSpi(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Returns the named child of this preference node, creating it if it does not already exist.                                                                                  |
| ` abstract `[String[]](https://developer.android.com/reference/java/lang/String)                               | ` `[childrenNamesSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childrenNamesSpi())`() ` Returns the names of the children of this preference node.                                                                                                                                                                                           |
| ` abstract void`                                                                                               | ` `[flushSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#flushSpi())`() ` This method is invoked with this node locked.                                                                                                                                                                                                                        |
| ` `[AbstractPreferences](https://developer.android.com/reference/java/util/prefs/AbstractPreferences)          | ` `[getChild](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getChild(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` nodeName) ` Returns the named child if it exists, ornullif it does not.                                                                                                             |
| ` abstract `[String](https://developer.android.com/reference/java/lang/String)                                 | ` `[getSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getSpi(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Return the value associated with the specified key at this preference node, ornullif there is no association for this key, or the association cannot be determined at this time. |
| ` boolean`                                                                                                     | ` `[isRemoved](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#isRemoved())`() ` Returnstrueiff this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method.                                                                                 |
| ` abstract `[String[]](https://developer.android.com/reference/java/lang/String)                               | ` `[keysSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#keysSpi())`() ` Returns all of the keys that have an associated value in this preference node.                                                                                                                                                                                         |
| ` abstract void`                                                                                               | ` `[putSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putSpi(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Put the given key-value association into this preference node.                   |
| ` abstract void`                                                                                               | ` `[removeNodeSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNodeSpi())`() ` Removes this preference node, invalidating it and any preferences that it contains.                                                                                                                                                                        |
| ` abstract void`                                                                                               | ` `[removeSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeSpi(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Remove the association (if any) for the specified key at this preference node.                                                                                             |
| ` abstract void`                                                                                               | ` `[syncSpi](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#syncSpi())`() ` This method is invoked with this node locked.                                                                                                                                                                                                                          |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.util.prefs.Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)` ` |------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[absolutePath](https://developer.android.com/reference/java/util/prefs/Preferences#absolutePath())`() ` Returns this preference node's absolute path name.                                                                                                                                                                                                                                                 | | ` abstract void`                                                                               | ` `[addNodeChangeListener](https://developer.android.com/reference/java/util/prefs/Preferences#addNodeChangeListener(java.util.prefs.NodeChangeListener))`(`[NodeChangeListener](https://developer.android.com/reference/java/util/prefs/NodeChangeListener)` ncl) ` Registers the specified listener to receive*node change events*for this node.                                                            | | ` abstract void`                                                                               | ` `[addPreferenceChangeListener](https://developer.android.com/reference/java/util/prefs/Preferences#addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener))`(`[PreferenceChangeListener](https://developer.android.com/reference/java/util/prefs/PreferenceChangeListener)` pcl) ` Registers the specified listener to receive*preference change events*for this preference node.             | | ` abstract `[String[]](https://developer.android.com/reference/java/lang/String)               | ` `[childrenNames](https://developer.android.com/reference/java/util/prefs/Preferences#childrenNames())`() ` Returns the names of the children of this preference node, relative to this node.                                                                                                                                                                                                                | | ` abstract void`                                                                               | ` `[clear](https://developer.android.com/reference/java/util/prefs/Preferences#clear())`() ` Removes all of the preferences (key-value associations) in this preference node.                                                                                                                                                                                                                                 | | ` abstract void`                                                                               | ` `[exportNode](https://developer.android.com/reference/java/util/prefs/Preferences#exportNode(java.io.OutputStream))`(`[OutputStream](https://developer.android.com/reference/java/io/OutputStream)` os) ` Emits on the specified output stream an XML document representing all of the preferences contained in this node (but not its descendants).                                                        | | ` abstract void`                                                                               | ` `[exportSubtree](https://developer.android.com/reference/java/util/prefs/Preferences#exportSubtree(java.io.OutputStream))`(`[OutputStream](https://developer.android.com/reference/java/io/OutputStream)` os) ` Emits an XML document representing all of the preferences contained in this node and all of its descendants.                                                                                | | ` abstract void`                                                                               | ` `[flush](https://developer.android.com/reference/java/util/prefs/Preferences#flush())`() ` Forces any changes in the contents of this preference node and its descendants to the persistent store.                                                                                                                                                                                                          | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[get](https://developer.android.com/reference/java/util/prefs/Preferences#get(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` def) ` Returns the value associated with the specified key in this preference node.                                                   | | ` abstract boolean`                                                                            | ` `[getBoolean](https://developer.android.com/reference/java/util/prefs/Preferences#getBoolean(java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` key, boolean def) ` Returns the boolean value represented by the string associated with the specified key in this preference node.                                                                         | | ` abstract byte[]`                                                                             | ` `[getByteArray](https://developer.android.com/reference/java/util/prefs/Preferences#getByteArray(java.lang.String,%20byte[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, byte[] def) ` Returns the byte array value represented by the string associated with the specified key in this preference node.                                                                    | | ` abstract double`                                                                             | ` `[getDouble](https://developer.android.com/reference/java/util/prefs/Preferences#getDouble(java.lang.String,%20double))`(`[String](https://developer.android.com/reference/java/lang/String)` key, double def) ` Returns the double value represented by the string associated with the specified key in this preference node.                                                                              | | ` abstract float`                                                                              | ` `[getFloat](https://developer.android.com/reference/java/util/prefs/Preferences#getFloat(java.lang.String,%20float))`(`[String](https://developer.android.com/reference/java/lang/String)` key, float def) ` Returns the float value represented by the string associated with the specified key in this preference node.                                                                                   | | ` abstract int`                                                                                | ` `[getInt](https://developer.android.com/reference/java/util/prefs/Preferences#getInt(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` key, int def) ` Returns the int value represented by the string associated with the specified key in this preference node.                                                                                             | | ` abstract long`                                                                               | ` `[getLong](https://developer.android.com/reference/java/util/prefs/Preferences#getLong(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` key, long def) ` Returns the long value represented by the string associated with the specified key in this preference node.                                                                                        | | ` static void`                                                                                 | ` `[importPreferences](https://developer.android.com/reference/java/util/prefs/Preferences#importPreferences(java.io.InputStream))`(`[InputStream](https://developer.android.com/reference/java/io/InputStream)` is) ` Imports all of the preferences represented by the XML document on the specified input stream.                                                                                          | | ` abstract boolean`                                                                            | ` `[isUserNode](https://developer.android.com/reference/java/util/prefs/Preferences#isUserNode())`() ` Returnstrueif this preference node is in the user preference tree,falseif it's in the system preference tree.                                                                                                                                                                                          | | ` abstract `[String[]](https://developer.android.com/reference/java/lang/String)               | ` `[keys](https://developer.android.com/reference/java/util/prefs/Preferences#keys())`() ` Returns all of the keys that have an associated value in this preference node.                                                                                                                                                                                                                                     | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[name](https://developer.android.com/reference/java/util/prefs/Preferences#name())`() ` Returns this preference node's name, relative to its parent.                                                                                                                                                                                                                                                       | | ` abstract `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences) | ` `[node](https://developer.android.com/reference/java/util/prefs/Preferences#node(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` pathName) ` Returns the named preference node in the same tree as this node, creating it and any of its ancestors if they do not already exist.                                                                                   | | ` abstract boolean`                                                                            | ` `[nodeExists](https://developer.android.com/reference/java/util/prefs/Preferences#nodeExists(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` pathName) ` Returns true if the named preference node exists in the same tree as this node.                                                                                                                           | | ` abstract `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences) | ` `[parent](https://developer.android.com/reference/java/util/prefs/Preferences#parent())`() ` Returns the parent of this preference node, ornullif this is the root.                                                                                                                                                                                                                                         | | ` abstract void`                                                                               | ` `[put](https://developer.android.com/reference/java/util/prefs/Preferences#put(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Associates the specified value with the specified key in this preference node.                                               | | ` abstract void`                                                                               | ` `[putBoolean](https://developer.android.com/reference/java/util/prefs/Preferences#putBoolean(java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` key, boolean value) ` Associates a string representing the specified boolean value with the specified key in this preference node.                                                                         | | ` abstract void`                                                                               | ` `[putByteArray](https://developer.android.com/reference/java/util/prefs/Preferences#putByteArray(java.lang.String,%20byte[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, byte[] value) ` Associates a string representing the specified byte array with the specified key in this preference node.                                                                          | | ` abstract void`                                                                               | ` `[putDouble](https://developer.android.com/reference/java/util/prefs/Preferences#putDouble(java.lang.String,%20double))`(`[String](https://developer.android.com/reference/java/lang/String)` key, double value) ` Associates a string representing the specified double value with the specified key in this preference node.                                                                              | | ` abstract void`                                                                               | ` `[putFloat](https://developer.android.com/reference/java/util/prefs/Preferences#putFloat(java.lang.String,%20float))`(`[String](https://developer.android.com/reference/java/lang/String)` key, float value) ` Associates a string representing the specified float value with the specified key in this preference node.                                                                                   | | ` abstract void`                                                                               | ` `[putInt](https://developer.android.com/reference/java/util/prefs/Preferences#putInt(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` key, int value) ` Associates a string representing the specified int value with the specified key in this preference node.                                                                                             | | ` abstract void`                                                                               | ` `[putLong](https://developer.android.com/reference/java/util/prefs/Preferences#putLong(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` key, long value) ` Associates a string representing the specified long value with the specified key in this preference node.                                                                                        | | ` abstract void`                                                                               | ` `[remove](https://developer.android.com/reference/java/util/prefs/Preferences#remove(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Removes the value associated with the specified key in this preference node, if any.                                                                                                                                   | | ` abstract void`                                                                               | ` `[removeNode](https://developer.android.com/reference/java/util/prefs/Preferences#removeNode())`() ` Removes this preference node and all of its descendants, invalidating any preferences contained in the removed nodes.                                                                                                                                                                                  | | ` abstract void`                                                                               | ` `[removeNodeChangeListener](https://developer.android.com/reference/java/util/prefs/Preferences#removeNodeChangeListener(java.util.prefs.NodeChangeListener))`(`[NodeChangeListener](https://developer.android.com/reference/java/util/prefs/NodeChangeListener)` ncl) ` Removes the specifiedNodeChangeListener, so it no longer receives change events.                                                   | | ` abstract void`                                                                               | ` `[removePreferenceChangeListener](https://developer.android.com/reference/java/util/prefs/Preferences#removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener))`(`[PreferenceChangeListener](https://developer.android.com/reference/java/util/prefs/PreferenceChangeListener)` pcl) ` Removes the specified preference change listener, so it no longer receives preference change events. | | ` abstract void`                                                                               | ` `[sync](https://developer.android.com/reference/java/util/prefs/Preferences#sync())`() ` Ensures that future reads from this preference node and its descendants reflect any changes that were committed to the persistent store (from any VM) prior to thesyncinvocation.                                                                                                                                  | | ` static `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)   | ` `[systemNodeForPackage](https://developer.android.com/reference/java/util/prefs/Preferences#systemNodeForPackage(java.lang.Class<?>))`(`[Class](https://developer.android.com/reference/java/lang/Class)`<?> c) ` **WARNING:**On Android, the Preference nodes corresponding to the "system" and "user" preferences are stored in sections of the file system that are inaccessible to apps.                | | ` static `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)   | ` `[systemRoot](https://developer.android.com/reference/java/util/prefs/Preferences#systemRoot())`() ` **WARNING:**On Android, the Preference nodes corresponding to the "system" and "user" preferences are stored in sections of the file system that are inaccessible to apps.                                                                                                                             | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[toString](https://developer.android.com/reference/java/util/prefs/Preferences#toString())`() ` Returns a string representation of this preferences node, as if computed by the expression:(this.isUserNode() ? "User" : "System") + " Preference Node: " + this.absolutePath().                                                                                                                           | | ` static `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)   | ` `[userNodeForPackage](https://developer.android.com/reference/java/util/prefs/Preferences#userNodeForPackage(java.lang.Class<?>))`(`[Class](https://developer.android.com/reference/java/lang/Class)`<?> c) ` **WARNING:**On Android, the Preference nodes corresponding to the "system" and "user" preferences are stored in sections of the file system that are inaccessible to apps.                    | | ` static `[Preferences](https://developer.android.com/reference/java/util/prefs/Preferences)   | ` `[userRoot](https://developer.android.com/reference/java/util/prefs/Preferences#userRoot())`() ` **WARNING:**On Android, the Preference nodes corresponding to the "system" and "user" preferences are stored in sections of the file system that are inaccessible to apps.                                                                                                                                 | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Fields

### lock

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected final Object lock
```

An object whose monitor is used to lock this node. This object is used in preference to the node itself to reduce the likelihood of intentional or unintentional denial of service due to a locked node. To avoid deadlock, a node is*never*locked by a thread that holds a lock on a descendant of that node.

<br />

### newNode

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected boolean newNode
```

This field should betrueif this node did not exist in the backing store prior to the creation of this object. The field is initialized to false, but may be set to true by a subclass constructor (and should not be modified thereafter). This field indicates whether a node change event should be fired when creation is complete.

<br />

## Protected constructors

### AbstractPreferences

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected AbstractPreferences (AbstractPreferences parent, 
                String name)
```

Creates a preference node with the specified parent and the specified name relative to its parent.

<br />

|                                                  Parameters                                                   ||
|----------|-----------------------------------------------------------------------------------------------------|
| `parent` | `AbstractPreferences`: the parent of this preference node, or null if this is the root. <br />      |
| `name`   | `String`: the name of this preference node, relative to its parent, or""if this is the root. <br /> |

|                                                                                Throws                                                                                 ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | ifnamecontains a slash ('/'), orparentisnulland name isn't"". |

## Public methods

### absolutePath

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String absolutePath ()
```

Implements theabsolutePathmethod as per the specification in[Preferences.absolutePath()](https://developer.android.com/reference/java/util/prefs/Preferences#absolutePath()).

This implementation merely returns the absolute path name that was computed at the time that this node was constructed (based on the name that was passed to this node's constructor, and the names that were passed to this node's ancestors' constructors).

<br />

|                                                        Returns                                                        ||
|--------------------------------------------------------------------|---------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | this preference node's absolute path name. <br /> |

### addNodeChangeListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void addNodeChangeListener (NodeChangeListener ncl)
```

Registers the specified listener to receive*node change events* for this node. A node change event is generated when a child node is added to or removed from this node. (A single[removeNode()](https://developer.android.com/reference/java/util/prefs/Preferences#removeNode())invocation results in multiple*node change events*, one for every node in the subtree rooted at the removed node.)

Events are only guaranteed for changes made within the same JVM as the registered listener, though some implementations may generate events for changes made outside this JVM. Events may be generated before the changes have become permanent. Events are not generated when indirect descendants of this node are added or removed; a caller desiring such events must register with each descendant.

Few guarantees can be made regarding node creation. Because nodes are created implicitly upon access, it may not be feasible for an implementation to determine whether a child node existed in the backing store prior to access (for example, because the backing store is unreachable or cached information is out of date). Under these circumstances, implementations are neither required to generate node change events nor prohibited from doing so.

<br />

|                            Parameters                            ||
|-------|-----------------------------------------------------------|
| `ncl` | `NodeChangeListener`: TheNodeChangeListenerto add. <br /> |

### addPreferenceChangeListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void addPreferenceChangeListener (PreferenceChangeListener pcl)
```

Registers the specified listener to receive*preference change events* for this preference node. A preference change event is generated when a preference is added to this node, removed from this node, or when the value associated with a preference is changed. (Preference change events are*not* generated by the[removeNode()](https://developer.android.com/reference/java/util/prefs/Preferences#removeNode())method, which generates a*node change event* . Preference change events*are* generated by theclearmethod.)

Events are only guaranteed for changes made within the same JVM as the registered listener, though some implementations may generate events for changes made outside this JVM. Events may be generated before the changes have been made persistent. Events are not generated when preferences are modified in descendants of this node; a caller desiring such events must register with each descendant.

<br />

|                                    Parameters                                    ||
|-------|---------------------------------------------------------------------------|
| `pcl` | `PreferenceChangeListener`: The preference change listener to add. <br /> |

### childrenNames

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String[] childrenNames ()
```

Implements thechildrenmethod as per the specification in[Preferences.childrenNames()](https://developer.android.com/reference/java/util/prefs/Preferences#childrenNames()).

This implementation obtains this preference node's lock, checks that the node has not been removed, constructs aTreeSetinitialized to the names of children already cached (the children in this node's "child-cache"), invokes[childrenNamesSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childrenNamesSpi()), and adds all of the returned child-names into the set. The elements of the tree set are dumped into aStringarray using thetoArraymethod, and this array is returned.

<br />

|                                                             Returns                                                             ||
|----------------------------------------------------------------------|-----------------------------------------------------------|
| [String[]](https://developer.android.com/reference/java/lang/String) | the names of the children of this preference node. <br /> |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.                                                      |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

**See also:**

- [cachedChildren()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#cachedChildren())  

### clear

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void clear ()
```

Implements theclearmethod as per the specification in[Preferences.clear()](https://developer.android.com/reference/java/util/prefs/Preferences#clear()).

This implementation obtains this preference node's lock, invokes[keys()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#keys())to obtain an array of keys, and iterates over the array invoking[remove(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#remove(java.lang.String))on each key.

<br />

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.                                                      |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### exportNode

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void exportNode (OutputStream os)
```

Implements theexportNodemethod as per the specification in[Preferences.exportNode(OutputStream)](https://developer.android.com/reference/java/util/prefs/Preferences#exportNode(java.io.OutputStream)).

<br />

|                                    Parameters                                     ||
|------|-----------------------------------------------------------------------------|
| `os` | `OutputStream`: the output stream on which to emit the XML document. <br /> |

|                                                                                   Throws                                                                                    ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException)                             | if writing to the specified output stream results in anIOException. |
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if preference data cannot be read from backing store.               |

### exportSubtree

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void exportSubtree (OutputStream os)
```

Implements theexportSubtreemethod as per the specification in[Preferences.exportSubtree(OutputStream)](https://developer.android.com/reference/java/util/prefs/Preferences#exportSubtree(java.io.OutputStream)).

<br />

|                                    Parameters                                     ||
|------|-----------------------------------------------------------------------------|
| `os` | `OutputStream`: the output stream on which to emit the XML document. <br /> |

|                                                                                   Throws                                                                                    ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException)                             | if writing to the specified output stream results in anIOException. |
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if preference data cannot be read from backing store.               |

### flush

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void flush ()
```

Implements theflushmethod as per the specification in[Preferences.flush()](https://developer.android.com/reference/java/util/prefs/Preferences#flush()).

This implementation calls a recursive helper method that locks this node, invokes flushSpi() on it, unlocks this node, and recursively invokes this method on each "cached child." A cached child is a child of this node that has been created in this VM and not subsequently removed. In effect, this method does a depth first traversal of the "cached subtree" rooted at this node, calling flushSpi() on each node in the subTree while only that node is locked. Note that flushSpi() is invoked top-down.

If this method is invoked on a node that has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method, flushSpi() is invoked on this node, but not on others.

<br />

|                                                                                                          Throws                                                                                                           ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it. |

**See also:**

- [flush()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#flush())  

### get

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String get (String key, 
                String def)
```

Implements thegetmethod as per the specification in[Preferences.get(String,String)](https://developer.android.com/reference/java/util/prefs/Preferences#get(java.lang.String,%20java.lang.String)).

This implementation first checks to see ifkeyisnullthrowing aNullPointerExceptionif this is the case. Then it obtains this preference node's lock, checks that the node has not been removed, invokes[getSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getSpi(java.lang.String)), and returns the result, unless thegetSpiinvocation returnsnullor throws an exception, in which case this invocation returnsdef.

<br />

|                                                        Parameters                                                        ||
|-------|-------------------------------------------------------------------------------------------------------------------|
| `key` | `String`: key whose associated value is to be returned. <br />                                                    |
| `def` | `String`: the value to be returned in the event that this preference node has no value associated withkey. <br /> |

|                                                                     Returns                                                                      ||
|--------------------------------------------------------------------|------------------------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the value associated withkey, ordefif no value is associated withkey. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)   | if key isnull. (Anulldefault*is*permitted.)                                                                                                                            |

### getBoolean

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean getBoolean (String key, 
                boolean def)
```

Implements thegetBooleanmethod as per the specification in[Preferences.getBoolean(String,boolean)](https://developer.android.com/reference/java/util/prefs/Preferences#getBoolean(java.lang.String,%20boolean)).

This implementation invokes[get(key, null)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#get(java.lang.String,%20java.lang.String)). If the return value is non-null, it is compared with"true"using[String.equalsIgnoreCase(String)](https://developer.android.com/reference/java/lang/String#equalsIgnoreCase(java.lang.String)). If the comparison returnstrue, this invocation returnstrue. Otherwise, the original return value is compared with"false", again using[String.equalsIgnoreCase(String)](https://developer.android.com/reference/java/lang/String#equalsIgnoreCase(java.lang.String)). If the comparison returnstrue, this invocation returnsfalse. Otherwise, this invocation returnsdef.

<br />

|                                                                                     Parameters                                                                                      ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `key` | `String`: key whose associated value is to be returned as a boolean. <br />                                                                                                  |
| `def` | `boolean`: the value to be returned in the event that this preference node has no value associated withkeyor the associated value cannot be interpreted as a boolean. <br /> |

|                                                                                           Returns                                                                                           ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | the boolean value represented by the string associated withkeyin this preference node, ordefif the associated value does not exist or cannot be interpreted as a boolean. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)   | ifkeyisnull.                                                                                                                                                           |

### getByteArray

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public byte[] getByteArray (String key, 
                byte[] def)
```

Implements thegetByteArraymethod as per the specification in[Preferences.getByteArray(String,byte[])](https://developer.android.com/reference/java/util/prefs/Preferences#getByteArray(java.lang.String,%20byte[])).

<br />

|                                                                                     Parameters                                                                                      ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `key` | `String`: key whose associated value is to be returned as a byte array. <br />                                                                                               |
| `def` | `byte`: the value to be returned in the event that this preference node has no value associated withkeyor the associated value cannot be interpreted as a byte array. <br /> |

|                                                                                             Returns                                                                                              ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `byte[]` | the byte array value represented by the string associated withkeyin this preference node, ordefif the associated value does not exist or cannot be interpreted as a byte array. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)   | ifkeyisnull. (Anullvalue fordef*is*permitted.)                                                                                                                         |

### getDouble

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public double getDouble (String key, 
                double def)
```

Implements thegetDoublemethod as per the specification in[Preferences.getDouble(String,double)](https://developer.android.com/reference/java/util/prefs/Preferences#getDouble(java.lang.String,%20double)).

This implementation invokes[get(key, null)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#get(java.lang.String,%20java.lang.String)). If the return value is non-null, the implementation attempts to translate it to andoublewith[Double.parseDouble(String)](https://developer.android.com/reference/java/lang/Double#parseDouble(java.lang.String)). If the attempt succeeds, the return value is returned by this method. Otherwise,defis returned.

<br />

|                                                                                    Parameters                                                                                     ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `key` | `String`: key whose associated value is to be returned as a double. <br />                                                                                                 |
| `def` | `double`: the value to be returned in the event that this preference node has no value associated withkeyor the associated value cannot be interpreted as a double. <br /> |

|                                                                                         Returns                                                                                          ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `double` | the double value represented by the string associated withkeyin this preference node, ordefif the associated value does not exist or cannot be interpreted as a double. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)   | ifkeyisnull.                                                                                                                                                           |

### getFloat

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public float getFloat (String key, 
                float def)
```

Implements thegetFloatmethod as per the specification in[Preferences.getFloat(String,float)](https://developer.android.com/reference/java/util/prefs/Preferences#getFloat(java.lang.String,%20float)).

This implementation invokes[get(key, null)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#get(java.lang.String,%20java.lang.String)). If the return value is non-null, the implementation attempts to translate it to anfloatwith[Float.parseFloat(String)](https://developer.android.com/reference/java/lang/Float#parseFloat(java.lang.String)). If the attempt succeeds, the return value is returned by this method. Otherwise,defis returned.

<br />

|                                                                                   Parameters                                                                                    ||
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `key` | `String`: key whose associated value is to be returned as a float. <br />                                                                                                |
| `def` | `float`: the value to be returned in the event that this preference node has no value associated withkeyor the associated value cannot be interpreted as a float. <br /> |

|                                                                                        Returns                                                                                        ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `float` | the float value represented by the string associated withkeyin this preference node, ordefif the associated value does not exist or cannot be interpreted as a float. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)   | ifkeyisnull.                                                                                                                                                           |

### getInt

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getInt (String key, 
                int def)
```

Implements thegetIntmethod as per the specification in[Preferences.getInt(String,int)](https://developer.android.com/reference/java/util/prefs/Preferences#getInt(java.lang.String,%20int)).

This implementation invokes[get(key, null)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#get(java.lang.String,%20java.lang.String)). If the return value is non-null, the implementation attempts to translate it to anintwith[Integer.parseInt(String)](https://developer.android.com/reference/java/lang/Integer#parseInt(java.lang.String)). If the attempt succeeds, the return value is returned by this method. Otherwise,defis returned.

<br />

|                                                                                  Parameters                                                                                  ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `key` | `String`: key whose associated value is to be returned as an int. <br />                                                                                              |
| `def` | `int`: the value to be returned in the event that this preference node has no value associated withkeyor the associated value cannot be interpreted as an int. <br /> |

|                                                                                     Returns                                                                                      ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | the int value represented by the string associated withkeyin this preference node, ordefif the associated value does not exist or cannot be interpreted as an int. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)   | ifkeyisnull.                                                                                                                                                           |

### getLong

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long getLong (String key, 
                long def)
```

Implements thegetLongmethod as per the specification in[Preferences.getLong(String,long)](https://developer.android.com/reference/java/util/prefs/Preferences#getLong(java.lang.String,%20long)).

This implementation invokes[get(key, null)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#get(java.lang.String,%20java.lang.String)). If the return value is non-null, the implementation attempts to translate it to alongwith[Long.parseLong(String)](https://developer.android.com/reference/java/lang/Long#parseLong(java.lang.String)). If the attempt succeeds, the return value is returned by this method. Otherwise,defis returned.

<br />

|                                                                                  Parameters                                                                                   ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `key` | `String`: key whose associated value is to be returned as a long. <br />                                                                                               |
| `def` | `long`: the value to be returned in the event that this preference node has no value associated withkeyor the associated value cannot be interpreted as a long. <br /> |

|                                                                                      Returns                                                                                       ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the long value represented by the string associated withkeyin this preference node, ordefif the associated value does not exist or cannot be interpreted as a long. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)   | ifkeyisnull.                                                                                                                                                           |

### isUserNode

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean isUserNode ()
```

Implements theisUserNodemethod as per the specification in[Preferences.isUserNode()](https://developer.android.com/reference/java/util/prefs/Preferences#isUserNode()).

This implementation compares this node's root node (which is stored in a private field) with the value returned by[Preferences.userRoot()](https://developer.android.com/reference/java/util/prefs/Preferences#userRoot()). If the two object references are identical, this method returns true.

<br />

|                                                         Returns                                                          ||
|-----------|---------------------------------------------------------------------------------------------------------------|
| `boolean` | trueif this preference node is in the user preference tree,falseif it's in the system preference tree. <br /> |

### keys

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String[] keys ()
```

Implements thekeysmethod as per the specification in[Preferences.keys()](https://developer.android.com/reference/java/util/prefs/Preferences#keys()).

This implementation obtains this preference node's lock, checks that the node has not been removed and invokes[keysSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#keysSpi()).

<br />

|                                                                         Returns                                                                          ||
|----------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [String[]](https://developer.android.com/reference/java/lang/String) | an array of the keys that have an associated value in this preference node. <br /> |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.                                                      |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### name

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String name ()
```

Implements thenamemethod as per the specification in[Preferences.name()](https://developer.android.com/reference/java/util/prefs/Preferences#name()).

This implementation merely returns the name that was passed to this node's constructor.

<br />

|                                                             Returns                                                             ||
|--------------------------------------------------------------------|-------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | this preference node's name, relative to its parent. <br /> |

### node

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Preferences node (String path)
```

Implements thenodemethod as per the specification in[Preferences.node(String)](https://developer.android.com/reference/java/util/prefs/Preferences#node(java.lang.String)).

This implementation obtains this preference node's lock and checks that the node has not been removed. Ifpathis"", this node is returned; ifpathis"/", this node's root is returned. If the first character inpathis not'/', the implementation breakspathinto tokens and recursively traverses the path from this node to the named node, "consuming" a name and a slash frompathat each step of the traversal. At each step, the current node is locked and the node's child-cache is checked for the named node. If it is not found, the name is checked to make sure its length does not exceedMAX_NAME_LENGTH. Then the[childSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childSpi(java.lang.String))method is invoked, and the result stored in this node's child-cache. If the newly createdPreferencesobject's[newNode](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#newNode)field istrueand there are any node change listeners, a notification event is enqueued for processing by the event dispatch thread.

When there are no more tokens, the last value found in the child-cache or returned bychildSpiis returned by this method. If during the traversal, two"/"tokens occur consecutively, or the final token is"/"(rather than a name), an appropriateIllegalArgumentExceptionis thrown.

If the first character ofpathis'/'(indicating an absolute path name) this preference node's lock is dropped prior to breakingpathinto tokens, and this method recursively traverses the path starting from the root (rather than starting from this node). The traversal is otherwise identical to the one described for relative path names. Dropping the lock on this node prior to commencing the traversal at the root node is essential to avoid the possibility of deadlock, as per the[locking invariant](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#lock).

<br />

|                                Parameters                                ||
|--------|------------------------------------------------------------------|
| `path` | `String`: the path name of the preference node to return. <br /> |

|                                                          Returns                                                          ||
|------------------------------------------------------------------------------------|---------------------------------------|
| [Preferences](https://developer.android.com/reference/java/util/prefs/Preferences) | the specified preference node. <br /> |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the path name is invalid (i.e., it contains multiple consecutive slash characters, or ends with a slash character and is more than one character long).             |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### nodeExists

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean nodeExists (String path)
```

Implements thenodeExistsmethod as per the specification in[Preferences.nodeExists(String)](https://developer.android.com/reference/java/util/prefs/Preferences#nodeExists(java.lang.String)).

This implementation is very similar to[node(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#node(java.lang.String)), except that[getChild(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getChild(java.lang.String))is used instead of[childSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childSpi(java.lang.String)).

<br />

|                                      Parameters                                      ||
|--------|------------------------------------------------------------------------------|
| `path` | `String`: the path name of the node whose existence is to be checked. <br /> |

|                       Returns                        ||
|-----------|-------------------------------------------|
| `boolean` | true if the specified node exists. <br /> |

|                                                                                                                                                         Throws                                                                                                                                                         ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.                                                                                              |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the path name is invalid (i.e., it contains multiple consecutive slash characters, or ends with a slash character and is more than one character long).                                                     |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method andpathnameis not the empty string (""). |

### parent

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Preferences parent ()
```

Implements theparentmethod as per the specification in[Preferences.parent()](https://developer.android.com/reference/java/util/prefs/Preferences#parent()).

This implementation obtains this preference node's lock, checks that the node has not been removed and returns the parent value that was passed to this node's constructor.

<br />

|                                                            Returns                                                             ||
|------------------------------------------------------------------------------------|--------------------------------------------|
| [Preferences](https://developer.android.com/reference/java/util/prefs/Preferences) | the parent of this preference node. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void put (String key, 
                String value)
```

Implements theputmethod as per the specification in[Preferences.put(String,String)](https://developer.android.com/reference/java/util/prefs/Preferences#put(java.lang.String,%20java.lang.String)).

This implementation checks that the key and value are legal, obtains this preference node's lock, checks that the node has not been removed, invokes[putSpi(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#putSpi(java.lang.String,%20java.lang.String)), and if there are any preference change listeners, enqueues a notification event for processing by the event dispatch thread.

<br />

|                                    Parameters                                     ||
|---------|--------------------------------------------------------------------------|
| `key`   | `String`: key with which the specified value is to be associated. <br /> |
| `value` | `String`: value to be associated with the specified key. <br />          |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if key or value isnull.                                                                                                                                                |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | ifkey.length()exceedsMAX_KEY_LENGTHor ifvalue.lengthexceedsMAX_VALUE_LENGTH.                                                                                           |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### putBoolean

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void putBoolean (String key, 
                boolean value)
```

Implements theputBooleanmethod as per the specification in[Preferences.putBoolean(String,boolean)](https://developer.android.com/reference/java/util/prefs/Preferences#putBoolean(java.lang.String,%20boolean)).

This implementation translatesvalueto a string with[String.valueOf(boolean)](https://developer.android.com/reference/java/lang/String#valueOf(boolean))and invokes[put(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#put(java.lang.String,%20java.lang.String))on the result.

<br />

|                                       Parameters                                       ||
|---------|-------------------------------------------------------------------------------|
| `key`   | `String`: key with which the string form of value is to be associated. <br /> |
| `value` | `boolean`: value whose string form is to be associated with key. <br />       |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if key isnull.                                                                                                                                                         |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | ifkey.length()exceedsMAX_KEY_LENGTH.                                                                                                                                   |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### putByteArray

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void putByteArray (String key, 
                byte[] value)
```

Implements theputByteArraymethod as per the specification in[Preferences.putByteArray(String,byte[])](https://developer.android.com/reference/java/util/prefs/Preferences#putByteArray(java.lang.String,%20byte[])).

<br />

|                                       Parameters                                       ||
|---------|-------------------------------------------------------------------------------|
| `key`   | `String`: key with which the string form of value is to be associated. <br /> |
| `value` | `byte`: value whose string form is to be associated with key. <br />          |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if key or value isnull.                                                                                                                                                |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if key.length() exceeds MAX_KEY_LENGTH or if value.length exceeds MAX_VALUE_LENGTH\*3/4.                                                                               |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### putDouble

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void putDouble (String key, 
                double value)
```

Implements theputDoublemethod as per the specification in[Preferences.putDouble(String,double)](https://developer.android.com/reference/java/util/prefs/Preferences#putDouble(java.lang.String,%20double)).

This implementation translatesvalueto a string with[Double.toString(double)](https://developer.android.com/reference/java/lang/Double#toString(double))and invokes[put(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#put(java.lang.String,%20java.lang.String))on the result.

<br />

|                                       Parameters                                       ||
|---------|-------------------------------------------------------------------------------|
| `key`   | `String`: key with which the string form of value is to be associated. <br /> |
| `value` | `double`: value whose string form is to be associated with key. <br />        |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if key isnull.                                                                                                                                                         |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | ifkey.length()exceedsMAX_KEY_LENGTH.                                                                                                                                   |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### putFloat

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void putFloat (String key, 
                float value)
```

Implements theputFloatmethod as per the specification in[Preferences.putFloat(String,float)](https://developer.android.com/reference/java/util/prefs/Preferences#putFloat(java.lang.String,%20float)).

This implementation translatesvalueto a string with[Float.toString(float)](https://developer.android.com/reference/java/lang/Float#toString(float))and invokes[put(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#put(java.lang.String,%20java.lang.String))on the result.

<br />

|                                       Parameters                                       ||
|---------|-------------------------------------------------------------------------------|
| `key`   | `String`: key with which the string form of value is to be associated. <br /> |
| `value` | `float`: value whose string form is to be associated with key. <br />         |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if key isnull.                                                                                                                                                         |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | ifkey.length()exceedsMAX_KEY_LENGTH.                                                                                                                                   |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### putInt

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void putInt (String key, 
                int value)
```

Implements theputIntmethod as per the specification in[Preferences.putInt(String,int)](https://developer.android.com/reference/java/util/prefs/Preferences#putInt(java.lang.String,%20int)).

This implementation translatesvalueto a string with[Integer.toString(int)](https://developer.android.com/reference/java/lang/Integer#toString(int))and invokes[put(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#put(java.lang.String,%20java.lang.String))on the result.

<br />

|                                       Parameters                                       ||
|---------|-------------------------------------------------------------------------------|
| `key`   | `String`: key with which the string form of value is to be associated. <br /> |
| `value` | `int`: value whose string form is to be associated with key. <br />           |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if key isnull.                                                                                                                                                         |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | ifkey.length()exceedsMAX_KEY_LENGTH.                                                                                                                                   |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### putLong

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void putLong (String key, 
                long value)
```

Implements theputLongmethod as per the specification in[Preferences.putLong(String,long)](https://developer.android.com/reference/java/util/prefs/Preferences#putLong(java.lang.String,%20long)).

This implementation translatesvalueto a string with[Long.toString(long)](https://developer.android.com/reference/java/lang/Long#toString(long))and invokes[put(java.lang.String, java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#put(java.lang.String,%20java.lang.String))on the result.

<br />

|                                       Parameters                                       ||
|---------|-------------------------------------------------------------------------------|
| `key`   | `String`: key with which the string form of value is to be associated. <br /> |
| `value` | `long`: value whose string form is to be associated with key. <br />          |

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if key isnull.                                                                                                                                                         |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | ifkey.length()exceedsMAX_KEY_LENGTH.                                                                                                                                   |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

### remove

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void remove (String key)
```

Implements theremove(String)method as per the specification in[Preferences.remove(String)](https://developer.android.com/reference/java/util/prefs/Preferences#remove(java.lang.String)).

This implementation obtains this preference node's lock, checks that the node has not been removed, invokes[removeSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeSpi(java.lang.String))and if there are any preference change listeners, enqueues a notification event for processing by the event dispatch thread.

<br />

|                                      Parameters                                      ||
|-------|-------------------------------------------------------------------------------|
| `key` | `String`: key whose mapping is to be removed from the preference node. <br /> |

|                                                                                                                                  Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)   | .                                                                                                                                                                      |

### removeNode

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void removeNode ()
```

Implements theremoveNode()method as per the specification in[Preferences.removeNode()](https://developer.android.com/reference/java/util/prefs/Preferences#removeNode()).

This implementation checks to see that this node is the root; if so, it throws an appropriate exception. Then, it locks this node's parent, and calls a recursive helper method that traverses the subtree rooted at this node. The recursive method locks the node on which it was called, checks that it has not already been removed, and then ensures that all of its children are cached: The[childrenNamesSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childrenNamesSpi())method is invoked and each returned child name is checked for containment in the child-cache. If a child is not already cached, the[childSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childSpi(java.lang.String))method is invoked to create aPreferencesinstance for it, and this instance is put into the child-cache. Then the helper method calls itself recursively on each node contained in its child-cache. Next, it invokes[removeNodeSpi()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNodeSpi()), marks itself as removed, and removes itself from its parent's child-cache. Finally, if there are any node change listeners, it enqueues a notification event for processing by the event dispatch thread.

Note that the helper method is always invoked with all ancestors up to the "closest non-removed ancestor" locked.

<br />

|                                                                                                                                              Throws                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)                 | if this node (or an ancestor) has already been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if this method is invoked on the root node.                                                                                                                                    |
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException)           | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.                                                              |

### removeNodeChangeListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void removeNodeChangeListener (NodeChangeListener ncl)
```

Removes the specifiedNodeChangeListener, so it no longer receives change events.

<br />

|                             Parameters                              ||
|-------|--------------------------------------------------------------|
| `ncl` | `NodeChangeListener`: TheNodeChangeListenerto remove. <br /> |

### removePreferenceChangeListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void removePreferenceChangeListener (PreferenceChangeListener pcl)
```

Removes the specified preference change listener, so it no longer receives preference change events.

<br />

|                                     Parameters                                      ||
|-------|------------------------------------------------------------------------------|
| `pcl` | `PreferenceChangeListener`: The preference change listener to remove. <br /> |

### sync

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void sync ()
```

Implements thesyncmethod as per the specification in[Preferences.sync()](https://developer.android.com/reference/java/util/prefs/Preferences#sync()).

This implementation calls a recursive helper method that locks this node, invokes syncSpi() on it, unlocks this node, and recursively invokes this method on each "cached child." A cached child is a child of this node that has been created in this VM and not subsequently removed. In effect, this method does a depth first traversal of the "cached subtree" rooted at this node, calling syncSpi() on each node in the subTree while only that node is locked. Note that syncSpi() is invoked top-down.

<br />

|                                                                                                                                     Throws                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.                                                      |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. |

**See also:**

- [flush()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#flush())  

### toString

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String toString ()
```

Returns the absolute path name of this preferences node.

<br />

|                                                      Returns                                                      ||
|--------------------------------------------------------------------|-----------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string representation of the object. <br /> |

## Protected methods

### cachedChildren

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected final AbstractPreferences[] cachedChildren ()
```

Returns all known unremoved children of this node.

<br />

|                                                                         Returns                                                                         ||
|------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| [AbstractPreferences[]](https://developer.android.com/reference/java/util/prefs/AbstractPreferences) | all known unremoved children of this node. <br /> |

### childSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract AbstractPreferences childSpi (String name)
```

Returns the named child of this preference node, creating it if it does not already exist. It is guaranteed thatnameis non-null, non-empty, does not contain the slash character ('/'), and is no longer than[Preferences.MAX_NAME_LENGTH](https://developer.android.com/reference/java/util/prefs/Preferences#MAX_NAME_LENGTH)characters. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for any of these things.)

Finally, it is guaranteed that the named node has not been returned by a previous invocation of this method or[getChild(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#getChild(java.lang.String))after the last time that it was removed. In other words, a cached value will always be used in preference to invoking this method. Subclasses need not maintain their own cache of previously returned children.

The implementer must ensure that the returned node has not been removed. If a like-named child of this node was previously removed, the implementer must return a newly constructedAbstractPreferencesnode; once removed, anAbstractPreferencesnode cannot be "resuscitated."

If this method causes a node to be created, this node is not guaranteed to be persistent until theflushmethod is invoked on this node or one of its ancestors (or descendants).

This method is invoked with the lock on this node held.

<br />

|                                            Parameters                                            ||
|--------|------------------------------------------------------------------------------------------|
| `name` | `String`: The name of the child node to return, relative to this preference node. <br /> |

|                                                             Returns                                                              ||
|----------------------------------------------------------------------------------------------------|------------------------------|
| [AbstractPreferences](https://developer.android.com/reference/java/util/prefs/AbstractPreferences) | The named child node. <br /> |

### childrenNamesSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract String[] childrenNamesSpi ()
```

Returns the names of the children of this preference node. (The returned array will be of size zero if this node has no children.) This method need not return the names of any nodes already cached, but may do so without harm.

This method is invoked with the lock on this node held.

If this node throws aBackingStoreException, the exception will propagate out beyond the enclosing[childrenNames()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childrenNames())invocation.

<br />

|                                                                       Returns                                                                       ||
|----------------------------------------------------------------------|-------------------------------------------------------------------------------|
| [String[]](https://developer.android.com/reference/java/lang/String) | an array containing the names of the children of this preference node. <br /> |

|                                                                                                          Throws                                                                                                           ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it. |

### flushSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract void flushSpi ()
```

This method is invoked with this node locked. The contract of this method is to force any cached changes in the contents of this preference node to the backing store, guaranteeing their persistence. (It is perfectly possible that this node does not exist on the backing store, either because it has been deleted by another VM, or because it has not yet been created.) Note that this method should*not*flush the preferences in any subnodes of this node. If the backing store naturally flushes an entire subtree at once, the implementer is encouraged to override flush(), rather than merely overriding this method.

If this node throws aBackingStoreException, the exception will propagate out beyond the enclosing[flush()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#flush())invocation.

<br />

|                                                                                                          Throws                                                                                                           ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it. |

### getChild

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected AbstractPreferences getChild (String nodeName)
```

Returns the named child if it exists, ornullif it does not. It is guaranteed thatnodeNameis non-null, non-empty, does not contain the slash character ('/'), and is no longer than[Preferences.MAX_NAME_LENGTH](https://developer.android.com/reference/java/util/prefs/Preferences#MAX_NAME_LENGTH)characters. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for any of these things if he chooses to override this method.)

Finally, it is guaranteed that the named node has not been returned by a previous invocation of this method or[childSpi(String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childSpi(java.lang.String))after the last time that it was removed. In other words, a cached value will always be used in preference to invoking this method. (The implementor needn't maintain his own cache of previously returned children if he chooses to override this method.)

This implementation obtains this preference node's lock, invokes[childrenNames()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childrenNames())to get an array of the names of this node's children, and iterates over the array comparing the name of each child with the specified node name. If a child node has the correct name, the[childSpi(java.lang.String)](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#childSpi(java.lang.String))method is invoked and the resulting node is returned. If the iteration completes without finding the specified name,nullis returned.

<br />

|                             Parameters                             ||
|------------|--------------------------------------------------------|
| `nodeName` | `String`: name of the child to be searched for. <br /> |

|                                                                             Returns                                                                              ||
|----------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [AbstractPreferences](https://developer.android.com/reference/java/util/prefs/AbstractPreferences) | the named child if it exists, or null if it does not. <br /> |

|                                                                                                          Throws                                                                                                           ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it. |

### getSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract String getSpi (String key)
```

Return the value associated with the specified key at this preference node, ornullif there is no association for this key, or the association cannot be determined at this time. It is guaranteed thatkeyis non-null. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for either of these things.)

Generally speaking, this method should not throw an exception under any circumstances. If, however, if it does throw an exception, the exception will be intercepted and treated as anullreturn value.

This method is invoked with the lock on this node held.

<br />

|           Parameters            ||
|-------|--------------------------|
| `key` | `String`: the key <br /> |

|                                                                                                                       Returns                                                                                                                        ||
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the value associated with the specified key at this preference node, ornullif there is no association for this key, or the association cannot be determined at this time. <br /> |

### isRemoved

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected boolean isRemoved ()
```

Returnstrueiff this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. This method locks this node prior to returning the contents of the private field used to track this state.

<br />

|                                                                                            Returns                                                                                            ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | trueiff this node (or an ancestor) has been removed with the[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())method. <br /> |

### keysSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract String[] keysSpi ()
```

Returns all of the keys that have an associated value in this preference node. (The returned array will be of size zero if this node has no preferences.) It is guaranteed that this node has not been removed.

This method is invoked with the lock on this node held.

If this node throws aBackingStoreException, the exception will propagate out beyond the enclosing[keys()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#keys())invocation.

<br />

|                                                                         Returns                                                                          ||
|----------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [String[]](https://developer.android.com/reference/java/lang/String) | an array of the keys that have an associated value in this preference node. <br /> |

|                                                                                                          Throws                                                                                                           ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it. |

### putSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract void putSpi (String key, 
                String value)
```

Put the given key-value association into this preference node. It is guaranteed thatkeyandvalueare non-null and of legal length. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for any of these things.)

This method is invoked with the lock on this node held.

<br />

|             Parameters              ||
|---------|----------------------------|
| `key`   | `String`: the key <br />   |
| `value` | `String`: the value <br /> |

### removeNodeSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract void removeNodeSpi ()
```

Removes this preference node, invalidating it and any preferences that it contains. The named child will have no descendants at the time this invocation is made (i.e., the[Preferences.removeNode()](https://developer.android.com/reference/java/util/prefs/Preferences#removeNode())method invokes this method repeatedly in a bottom-up fashion, removing each of a node's descendants before removing the node itself).

This method is invoked with the lock held on this node and its parent (and all ancestors that are being removed as a result of a single invocation to[Preferences.removeNode()](https://developer.android.com/reference/java/util/prefs/Preferences#removeNode())).

The removal of a node needn't become persistent until theflushmethod is invoked on this node (or an ancestor).

If this node throws aBackingStoreException, the exception will propagate out beyond the enclosing[removeNode()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#removeNode())invocation.

<br />

|                                                                                                          Throws                                                                                                           ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it. |

### removeSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract void removeSpi (String key)
```

Remove the association (if any) for the specified key at this preference node. It is guaranteed thatkeyis non-null. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for either of these things.)

This method is invoked with the lock on this node held.

<br />

|           Parameters            ||
|-------|--------------------------|
| `key` | `String`: the key <br /> |

### syncSpi

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract void syncSpi ()
```

This method is invoked with this node locked. The contract of this method is to synchronize any cached preferences stored at this node with any stored in the backing store. (It is perfectly possible that this node does not exist on the backing store, either because it has been deleted by another VM, or because it has not yet been created.) Note that this method should*not*synchronize the preferences in any subnodes of this node. If the backing store naturally syncs an entire subtree at once, the implementer is encouraged to override sync(), rather than merely overriding this method.

If this node throws aBackingStoreException, the exception will propagate out beyond the enclosing[sync()](https://developer.android.com/reference/java/util/prefs/AbstractPreferences#sync())invocation.

<br />

|                                                                                                          Throws                                                                                                           ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [BackingStoreException](https://developer.android.com/reference/java/util/prefs/BackingStoreException) | if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it. |