// Creating a new parcel Parcel parcel; // Writing data to the parcel parcel.writeInt(123); parcel.writeFloat(2.3); parcel.writeString("Hello World!"); // Setting the data position to the start of the parcel parcel.setDataPosition(0); // Reading data from the parcel int intValue = parcel.readInt(); float floatValue = parcel.readFloat(); String strValue = parcel.readString();
// Creating a new parcel Parcel parcel; // Writing data to the parcel parcel.writeByte(1); parcel.writeDouble(4.5); parcel.writeString("Hello"); // Skipping the first two bytes parcel.setDataPosition(2); // Reading data from the parcel double doubleValue = parcel.readDouble(); String strValue = parcel.readString();This example demonstrates the usage of setDataPosition to skip the first two bytes of data written to the parcel. It is then used to read the remaining data from the parcel. Package Library: The Parcel class and its methods including setDataPosition are available in the Android OS library as part of the Android framework in the "android.os" package.