public
final
class
FileListingService
extends Object
| java.lang.Object | |
| ↳ | com.android.ddmlib.FileListingService |
Provides IDevice side file listing service.
classFileListingService.FileEntry
Represents an entry in a directory.
interfaceFileListingService.IListingReceiver
Classes which implement this interface provide a method that deals with asynchronous result
from ls command on the device.
Constants | |
|---|---|
String |
DIRECTORY_APP
Application folder. |
String |
DIRECTORY_DATA
Top level data folder. |
String |
DIRECTORY_MNT
Top level mount folder. |
String |
DIRECTORY_SDCARD
Top level sdcard folder. |
String |
DIRECTORY_SYSTEM
Top level system folder. |
String |
DIRECTORY_TEMP
Top level temp folder. |
String |
FILE_SEPARATOR
Device side file separator. |
long |
REFRESH_RATE
|
int |
TYPE_BLOCK
Entry type: Block |
int |
TYPE_CHARACTER
Entry type: Character |
int |
TYPE_DIRECTORY
Entry type: Directory |
int |
TYPE_DIRECTORY_LINK
Entry type: Directory Link |
int |
TYPE_FIFO
Entry type: FIFO |
int |
TYPE_FILE
Entry type: File |
int |
TYPE_LINK
Entry type: Link |
int |
TYPE_OTHER
Entry type: Other |
int |
TYPE_SOCKET
Entry type: Socket |
Fields | |
|---|---|
public
static
final
Pattern |
LS_LD_PATTERN
|
public
static
final
Pattern |
LS_L_PATTERN
Regexp pattern to parse the result from ls. |
public
static
final
Pattern |
STAT_PATTERN
Regexp pattern to parse the result from stat. |
Public constructors | |
|---|---|
FileListingService(IDevice device)
Creates a File Listing Service for a specified |
|
Public methods | |
|---|---|
FileEntry[]
|
getChildren(FileListingService.FileEntry entry, boolean useCache, FileListingService.IListingReceiver receiver)
Returns the children of a |
static
FileEntry[]
|
getChildrenSync(FileListingService.FileEntry entry, INativeDevice device)
Returns the children of a |
FileListingService.FileEntry
|
getRoot()
Returns the root element. |
public static final String DIRECTORY_APP
Application folder.
Constant Value: "app"
public static final String DIRECTORY_DATA
Top level data folder.
Constant Value: "data"
public static final String DIRECTORY_MNT
Top level mount folder.
Constant Value: "mnt"
public static final String DIRECTORY_SDCARD
Top level sdcard folder.
Constant Value: "sdcard"
public static final String DIRECTORY_SYSTEM
Top level system folder.
Constant Value: "system"
public static final String DIRECTORY_TEMP
Top level temp folder.
Constant Value: "tmp"
public static final String FILE_SEPARATOR
Device side file separator.
Constant Value: "/"
public static final long REFRESH_RATE
Constant Value: 5000 (0x0000000000001388)
public static final int TYPE_BLOCK
Entry type: Block
Constant Value: 3 (0x00000003)
public static final int TYPE_CHARACTER
Entry type: Character
Constant Value: 4 (0x00000004)
public static final int TYPE_DIRECTORY
Entry type: Directory
Constant Value: 1 (0x00000001)
public static final int TYPE_DIRECTORY_LINK
Entry type: Directory Link
Constant Value: 2 (0x00000002)
public static final int TYPE_FIFO
Entry type: FIFO
Constant Value: 7 (0x00000007)
public static final int TYPE_FILE
Entry type: File
Constant Value: 0 (0x00000000)
public static final int TYPE_LINK
Entry type: Link
Constant Value: 5 (0x00000005)
public static final int TYPE_OTHER
Entry type: Other
Constant Value: 8 (0x00000008)
public static final int TYPE_SOCKET
Entry type: Socket
Constant Value: 6 (0x00000006)
public static final Pattern LS_LD_PATTERN
public static final Pattern LS_L_PATTERN
Regexp pattern to parse the result from ls.
public static final Pattern STAT_PATTERN
Regexp pattern to parse the result from stat. Ex. drwxr-xr-x root root 2021-08-02 09:20:53.000000000 -0700 4096 /
public FileListingService (IDevice device)
Creates a File Listing Service for a specified IDevice.
| Parameters | |
|---|---|
device |
IDevice: The Device the service is connected to. |
public FileEntry[] getChildren (FileListingService.FileEntry entry, boolean useCache, FileListingService.IListingReceiver receiver)
Returns the children of a FileEntry.
This method supports a cache mechanism and synchronous and asynchronous modes.
If receiver is null, the device side ls command is
done synchronously, and the method will return upon completion of the command.
If receiver is non null, the command is launched is a separate thread
and upon completion, the receiver will be notified of the result.
The result for each ls command is cached in the parent FileEntry
. useCache allows usage of this cache, but only if the cache is valid. The cache
is valid only for FileListingService.REFRESH_RATE ms. After that a new ls
command is always executed.
If the cache is valid and useCache == true, the method will always simply
return the value of the cache, whether a IListingReceiver has been provided or not.
| Parameters | |
|---|---|
entry |
FileListingService.FileEntry: The parent entry. |
useCache |
boolean: A flag to use the cache or to force a new ls command. |
receiver |
FileListingService.IListingReceiver: A receiver for asynchronous calls. |
| Returns | |
|---|---|
FileEntry[] |
The list of children or null for asynchronous calls. |
See also:
public static FileEntry[] getChildrenSync (FileListingService.FileEntry entry, INativeDevice device)
Returns the children of a FileEntry.
This method is the explicit synchronous version of getChildren(FileEntry,boolean,IListingReceiver). It is roughly equivalent to calling getChildren(FileEntry, false, null)
| Parameters | |
|---|---|
entry |
FileListingService.FileEntry: The parent entry. |
device |
INativeDevice |
| Returns | |
|---|---|
FileEntry[] |
The list of children |
| Throws | |
|---|---|
AdbCommandRejectedException |
if adb rejects the command. |
ShellCommandUnresponsiveException |
in case the shell command doesn't send any output for a period longer than maxTimeToOutputResponse. |
TimeoutException |
in case of timeout on the connection when sending the command. |
IOException |
in case of I/O error on the connection. |
DeviceNotAvailableException |
|
public FileListingService.FileEntry getRoot ()
Returns the root element.
| Returns | |
|---|---|
FileListingService.FileEntry |
the FileEntry object representing the root element or null if
the device is invalid. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-22 UTC.