Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This section presents the new technologies that we use in the Enhanced Slideshow app.
The app stores slideshows on the device for viewing later. Earlier apps showed techniques for saving text data in key–value pairs. This app stores entire SlideshowInfo objects using object serialization (Section 13.5.3). A serialized object is represented as a sequence of bytes that includes the object’s data and information about the object’s type.
The serialization capabilities are located in package java.io. To use an object with the serialization mechanism, the object’s class must implement the Serializable interface, which is a tagging interface. Such an interface does not contain methods. Objects of a class that implements Serializable are tagged as being Serializable objects—that is, any object of a class that implements Serializable is a Serializable object. An ObjectOutputStream serializes Serializable objects to a specified OutputSteam—in this app, a FileOutputStream. Tagging objects as Serializable is important, because an ObjectOutputStream output only Serializable objects.