Wrapper of android.os.FileObserver
for observing files within the BlackBerry Dynamics secure file system.
More...
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.
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 FileObs erver(com.good.gd.file.File) instead. More... | |
FileObserver (String path, int mask) | |
This constructor is deprecated, use FileObs erver(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. | |
FileObserver | ( | com.good.gd.file.File | file | ) |
Call this constructor to create a new instance from a File
Object.
Equivalent to FileObs
erver(file, FileObserver.ALL_EVENTS)
.
file | File containing the absolute path, within the secure file system. This value cannot be null |
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.
file | File containing the absolute path, within the secure file system. This value cannot be null |
mask | The event or events (added together) to watch for |
FileObserver | ( | List< com.good.gd.file.File > | files | ) |
Call this constructor to create a new instance from a List
of File
Objects.
Equivalent to FileObs
erver(files, FileObserver.ALL_EVENTS)
.
files | List of File containing the absolute path, within the secure file system. This value cannot be null |
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.
files | List of File containing the absolute path, within the secure file system. This value cannot be null |
mask | The event or events (added together) to watch for |
FileObserver | ( | String | path | ) |
FileObs
erver(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 FileObs
erver(path, FileObserver.ALL_EVENTS)
.
path | The absolute path within the secure store of the file or directory to monitor |
FileObserver | ( | String | path, |
int | mask | ||
) |
FileObs
erver(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.
path | The absolute path within the secure store of the file or directory to monitor |
mask | The event or events (added together) to watch for |
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.
IOException |
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.
IOException |
|
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.
event | The type of event which happened |
path | The absolute path within the secure file system of the file or directory which triggered the event |