Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8129551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:21:19+00:00 2026-06-06T08:21:19+00:00

I tried to listen file change event in BlackBerry base on FileExplorer example, but

  • 0

I tried to listen file change event in BlackBerry base on FileExplorer example, but whenever I added or deleted file, it always showed “Deferring persistence as device is being used” and I can’t catch anything .
Here is my code:

public class FileChangeListenner implements FileSystemJournalListener{

private long _lastUSN; // = 0;     
public void fileJournalChanged() {
    long nextUSN = FileSystemJournal.getNextUSN();
    String msg = null;       
    for (long lookUSN = nextUSN - 1; lookUSN >= _lastUSN && msg == null; --lookUSN) 
    {
        FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);
        // We didn't find an entry
        if (entry == null) 
        { 
            break;
        }
        // Check if this entry was added or deleted
        String path = entry.getPath();            
        if (path != null) 
        {  
            switch (entry.getEvent()) 
            {
                case FileSystemJournalEntry.FILE_ADDED:
                    msg = "File was added.";                       
                    break;

                case FileSystemJournalEntry.FILE_DELETED:
                    msg = "File was deleted.";
                    break;
            }
        }
    }        
    _lastUSN = nextUSN;        
    if ( msg != null ) 
    {           
        System.out.println(msg);
    }
}
}

Here is the caller:

Thread t = new Thread(new Runnable() {
            public void run() {
                new FileChangeListenner();
                try {
                    Thread.sleep(5000);
                    createFile();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }                   
            }
        });
        t.start();

Create file method worked fine:

   private void createFile() {
    try {
        FileConnection fc = (FileConnection) Connector
                .open("file:///SDCard/newfile.txt");
        // If no exception is thrown, then the URI is valid, but the file
        // may or may not exist.
        if (!fc.exists()) {
            fc.create(); // create the file if it doesn't exist
        }
        OutputStream outStream = fc.openOutputStream();
        outStream.write("test content".getBytes());
        outStream.close();
        fc.close();
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

and output:

 0:00:44.475: Deferring persistence as device is being used.
 0:00:46.475: AG,+CPT
 0:00:46.477: AG,-CPT
 0:00:54.476: VM:+GC(f)w=11
 0:00:54.551: VM:-GCt=9,b=1,r=0,g=f,w=11,m=0
 0:00:54.553: VM:QUOT t=1
 0:00:54.554: VM:+CR
 0:00:54.596: VM:-CR t=5
 0:00:55.476: AM: Exit net_rim_bb_datatags(291)
 0:00:55.478: Process net_rim_bb_datatags(291) cleanup started
 0:00:55.479: VM:EVTOv=7680,w=20
 0:00:55.480: Process net_rim_bb_datatags(291) cleanup done
 0:00:55.481: 06/25 03:40:41.165 BBM FutureTask Execute: net.rim.device.apps.internal.qm.bbm.platform.BBMPlatformManagerImpl$3@d1e1ec79
 0:00:55.487: 06/25 03:40:41.171 BBM FutureTask Finish : net.rim.device.apps.internal.qm.bbm.platform.BBMPlatformManagerImpl$3@d1e1ec79

I also tried to remove the thread or create or delete file in simulator ‘s sdcard directly but it doesn’t help.
Please tell me where is my problem. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:21:22+00:00Added an answer on June 6, 2026 at 8:21 am

    You instantiate the FileChangeListenner, but you never register it, and also don’t keep it as a variable anywhere. You probably need to add this call

    FileChangeListenner listener = new FileChangeListenner();
    UiApplication.getUiApplication().addFileSystemJournalListener(listener);
    

    You also might need to keep a reference (listener) around for as long as you want to receive events. But maybe not (the addFileSystemJournalListener() call might do that). But, you at least need that call to addFileSystemJournalListener(), or you’ll never get fileJournalChanged() called back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

tried uncommenting pam_limits.so from the pam.d directory but no luck. Basic PAM seems to
Tried searching the site, but cannot find an answer to my problem: Lets say
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
Tried a bunch of things but I can't get it to work consistently amid
tried to find the answer by googling and in MSDN but with no luck.
Tried to create a mobile navigation using dataview or outline and the view renders
Tried to search for this online and didn't get very far, so I'm asking
Tried following the instructions here: How to use Google app engine with my own
Tried to make a little old school ajax (iframe-javascript) script. A bit of mootools
I was playing around with some chrome extensions and I found this example: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_url/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.