Skip to main content
Version: 1.0.0

read

Read file content on the device filesystem.

declare class AdbSync {
read(filename: string): ReadableStream<Uint8Array>;
}
READ ALL STREAMS!

ADB is a multiplexing protocol (multiple logic streams are transferred over one connection), so blocking one stream will block all other streams.

You must continuously read from all incoming streams (either by piping them to WritableStreams or calling reader.read() in a loop) to prevent this from happening.

If the remaining data is not needed, stream.cancel() (or reader.cancel() if using a reader) can be called to discard them.

Example

const content = sync.read("/sdcard/Download/hello.txt");
await content.pipeTo(
new WritableStream({
write(chunk) {
console.log(chunk);
},
}),
);
Equivalent ADB Command
adb pull /sdcard/Download/hello.txt