Code example for RandomAccessFile

Methods: setLength, writeBoolean, writeInt

0
     * Handy helper routine to write the UI data to a file. 
     */ 
    void writeDataToFileLocked(RandomAccessFile file,
            boolean addMayo, boolean addTomato, int whichFilling)
        throws IOException { 
            file.setLength(0L);
            file.writeInt(whichFilling);
            file.writeBoolean(addMayo);
            file.writeBoolean(addTomato);
            Log.v(TAG, "NEW STATE: mayo=" + addMayo
                    + " tomato=" + addTomato
                    + " filling=" + whichFilling);
    } 
 
    /** 
     * Another helper; this one reads the current UI state and writes that 
     * to the persistent store, then tells the backup manager that we need 
     * a backup. 
     */ 
    void recordNewUIState() { 
        boolean addMayo = mAddMayoCheckbox.isChecked();