• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.1.1.43
FileObserver Class Referenceabstract

Wrapper of android.os.FileObserver for observing files within the BlackBerry Dynamics secure file system. More...

Description

This class is a wrappper class of android.os.FileObserver for observing files within the BlackBerry Dynamics secure file system.

See the com.good.gd.file package documentation for an introduction to the secure file system.

This class has the same programming interface as the android.os.FileObserver class, with the exception of elements of that class which have already been deprecated.

See also
android.os.FileObserver class reference on the android.com developer website for details of all methods.

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

 FileObserver (com.good.gd.file.File file)
 Construct new instance from a File object. More...
 
 FileObserver (com.good.gd.file.File file, int mask)
 Construct new instance from a File object and a mask. More...
 
 FileObserver (List< com.good.gd.file.File > files)
 Construct new instance from a File object. More...
 
 FileObserver (List< com.good.gd.file.File > files, int mask)
 Construct new instance from a List of File objects and a mask. More...
 
 FileObserver (String path)
 This constructor is deprecated, use FileObserver(com.good.gd.file.File) instead. More...
 
 FileObserver (String path, int mask)
 This constructor is deprecated, use FileObserver(com.good.gd.file.File, int) instead. More...
 
void startWatching () throws IOException
 Start watching for events. More...
 
void stopWatching () throws IOException
 Stop watching for events. More...
 
abstract void onEvent (int event, String path)
 The event handler, which must be implemented by subclasses. More...
 

Static Public Attributes

static final int ACCESS = 0x00000001
 Event type: Data was read from a file Constant Value: 1.
 
static final int MODIFY = 0x00000002
 Event type: Data was written to a file Constant Value: 2.
 
static final int ATTRIB = 0x00000004
 Event type: Metadata (permissions, owner, timestamp) was changed explicitly Constant Value: 4.
 
static final int CLOSE_WRITE = 0x00000008
 Event type: Someone had a file or directory open for writing, and closed it Constant Value: 8.
 
static final int CLOSE_NOWRITE = 0x00000010
 Event type: Someone had a file or directory open read-only, and closed it Constant Value: 16.
 
static final int OPEN = 0x00000020
 Event type: A file or directory was opened Constant Value: 32.
 
static final int MOVED_FROM = 0x00000040
 Event type: A file or subdirectory was moved from the monitored directory Constant Value: 64.
 
static final int MOVED_TO = 0x00000080
 Event type: A file or subdirectory was moved to the monitored directory Constant Value: 128.
 
static final int CREATE = 0x00000100
 Event type: A new file or subdirectory was created under the monitored directory Constant Value: 256.
 
static final int DELETE = 0x00000200
 Event type: A file was deleted from the monitored directory Constant Value: 512.
 
static final int DELETE_SELF = 0x00000400
 Event type: The monitored file or directory was deleted; monitoring effectively stops Constant Value: 1024.
 
static final int MOVE_SELF = 0x00000800
 Event type: The monitored file or directory was moved; monitoring continues Constant Value: 2048.
 
static final int ALL_EVENTS
 Event mask: All valid event types, combined Constant Value: 4095.
 

Constructor & Destructor Documentation

◆ FileObserver() [1/6]

Call this constructor to create a new instance from a File Object.

Equivalent to FileObserver(file, FileObserver.ALL_EVENTS).

Parameters
fileFile containing the absolute path, within the secure file system. This value cannot be null

◆ FileObserver() [2/6]

FileObserver ( com.good.gd.file.File  file,
int  mask 
)

Call this constructor to create a new instance from a File Object and a mask of the event or events (added together) to watch for.

You must call startWatching() before you will receive events.

Parameters
fileFile containing the absolute path, within the secure file system. This value cannot be null
maskThe event or events (added together) to watch for

◆ FileObserver() [3/6]

FileObserver ( List< com.good.gd.file.File files)

Call this constructor to create a new instance from a List of File Objects.

Equivalent to FileObserver(files, FileObserver.ALL_EVENTS).

Parameters
filesList of File containing the absolute path, within the secure file system. This value cannot be null

◆ FileObserver() [4/6]

FileObserver ( List< com.good.gd.file.File files,
int  mask 
)

Call this constructor to create a new instance from a List of File Objects and a mask of the event or events (added together) to watch for.

Parameters
filesList of File containing the absolute path, within the secure file system. This value cannot be null
maskThe event or events (added together) to watch for

◆ FileObserver() [5/6]

FileObserver ( String  path)
Deprecated:
This constructor is deprecated. Use FileObserver(com.good.gd.file.File) instead.

Call this constructor to create a new instance from a String with the absolute path of the file or directory within the secure store.

Equivalent to FileObserver(path, FileObserver.ALL_EVENTS).

Parameters
pathThe absolute path within the secure store of the file or directory to monitor

◆ FileObserver() [6/6]

FileObserver ( String  path,
int  mask 
)
Deprecated:
This constructor is deprecated. Use FileObserver(com.good.gd.file.File, int) instead.

Call this constructor to create a new instance from a String with the absolute path of the file or directory within the secure store and a mask of the event or events (added together) to watch for.

You must call startWatching() before you will receive events.

Parameters
pathThe absolute path within the secure store of the file or directory to monitor
maskThe event or events (added together) to watch for

Member Function Documentation

◆ startWatching()

void startWatching ( ) throws IOException

Start watching for events. The monitored file or directory must exist at this time, or else no events will be reported (even if it appears later). If monitoring is already started, this call has no effect.

Exceptions
IOException

◆ stopWatching()

void stopWatching ( ) throws IOException

Stop watching for events. Some events may be in process, so events may continue to be reported even after this method completes. If monitoring is already stopped, this call has no effect.

Exceptions
IOException

◆ onEvent()

abstract void onEvent ( int  event,
String  path 
)
abstract

NOTE: This method is invoked on a special FileObserver thread. It runs independently of any threads, so take care to use appropriate synchronization! Consider using Handler::post(Runnable) to shift event handling work to the main thread to avoid concurrency problems.

Event handlers must not throw exceptions.

Parameters
eventThe type of event which happened
pathThe absolute path within the secure file system of the file or directory which triggered the event