Code example for RandomAccessFile

Methods: close, readByte

0
     * @return Whether a saved pattern exists. 
     */ 
    public boolean savedPatternExists() { 
        try { 
            // Check if we can read a byte from the file 
            RandomAccessFile raf = new RandomAccessFile(sLockPatternFilename, "r");
            byte first = raf.readByte();
            raf.close();
            return true; 
        } catch (FileNotFoundException fnfe) {
            return false; 
        } catch (IOException ioe) {
            return false; 
        } 
    } 
 
    /** 
     * Return true if the user has ever chosen a pattern.  This is true even if the pattern is 
     * currently cleared. 
     * 
     * @return True if the user has ever chosen a pattern.