net.rim.device.api.io.file
Class FileSystemJournal

java.lang.Object
  extended by net.rim.device.api.io.file.FileSystemJournal

public final class FileSystemJournal
extends Object

This class represents a file system journal. The journal tracks changes to the file system and applications can query the entries. The journal has limited space so applications should be aware that not all changes are stored and that journal changes may be lost after a reset. For optimality, it is stressed that iteration be done backwards from the next USN to the cached value of the application or until a null journal entry is reached. An example of the code is provided below, which involves querying the journal and looking for a previously-added file with the name "mindwave".

   long nextUSN = FileSystemJournal.getNextUSN();
   for (long lookUSN = nextUSN-1; lookUSN >= _myStoredUSN; lookUSN--) {
       FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);

       if (entry == null) {
           // we didn't find an entry.
           break;
       }

       if (entry.getEvent() == FileSystemJournalEntry.FILE_ADDED) {
           String path = entry.getPath();
           if (path != null && path.indexOf("mindwave") != -1) {
               System.out.println("Found a file added named mindwave");
               break;
           }
       }
   }
   _myStoredUSN = nextUSN;

   

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.2.0

Method Summary
Category: Signed static FileSystemJournalEntry getEntry(long usn)
          Retrieve a journal entry for corresponding USN.
Category: Signed static long getNextUSN()
          This method returns the next USN (Update Sequence Number) that the journal system will use.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Method Detail

getNextUSN

public static long getNextUSN()
This method returns the next USN (Update Sequence Number) that the journal system will use.

Returns:
The next USN to be used.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.2.0

getEntry

public static FileSystemJournalEntry getEntry(long usn)
Retrieve a journal entry for corresponding USN. This method will return null if the update sequence number is out of range of the current stored values. It is recommended that once an application retrieves a null journal entry that iteration stop.

Parameters:
usn - The update sequence number of the entry to be retrieved.
Returns:
The corresponding update sequence number, possibly null.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.2.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.