android - 我如何读取连接到 Android 设备的 USB 闪存的第一个扇区?

标签 android random-access sector

我想读取连接到 android 平板电脑的 USB 闪存的第一个扇区或第一个字节!

我知道应该使用 RandomAccessFile,但我不知道我的 USB 闪存的地址是什么!

谢谢你的帮助


我找到了这段代码,但我不知道应该用什么代替 args[0]

public class FAT16
{
public static void main(String[] args) throws IOException
{
// open file whose name is on the command line for input

RandomAccessFile file = new RandomAccessFile(args[0], "r");

// skip ahead to byte 19 (0x13 hex) where the num of sectors is stored

file.seek(0x13);

// 2-byte values are little-endian; Java is big-endian, so we
// have to read the two bytes separately and glue them together
// ourselves

int low = file.readUnsignedByte();
int high = file.readUnsignedByte();

int sectorsOnDisk = low + (high * 256);

// skip ahead to where the sectors per FAT is stored

file.seek(0x16);
low = file.readUnsignedByte();
high = file.readUnsignedByte();

int sectorsPerFAT = low + high * 256;

// skip back to where the bytes per sector is stored

file.seek(0x0b);
low = file.readUnsignedByte();
high = file.readUnsignedByte();
int bytesPerSector = low + high * 256;

// report size of disk and number of sectors per FAT

System.out.println("Disk size = " + sectorsOnDisk * bytesPerSector );
System.out.println("Sectors per FAT = " + sectorsPerFAT);
}

我知道我们应该在 linux 中使用“/dev/sdaX”,但它对于 adnroid 来说是什么?

最佳答案

Android SDK 不支持“USB 闪存”。请咨询您的设备制造商,了解他们是否有用于访问其设备上的“USB 闪存”的特定协议(protocol)。

关于android - 我如何读取连接到 Android 设备的 USB 闪存的第一个扇区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9081091/

相关文章:

android - 测试应用更新时,Android 版本构建签名的 APK 安装被静默阻止

c++ - STL什么是随机访问和顺序访问?

file - Avro hadoop随机访问文件

c - 覆盖文件时写入的扇区?

objective-c - 如何正确填充圆弧扇区 NSBezierPath,Objective-C

android - 如何为xamarin android实现推送通知

android - 将请求排队到 DownloadManager 时应用程序崩溃

java - FileInputStream.skip() 是否进行搜索?

linux - 读取 FAT32 文件系统的引导扇区

android - 如何让图标显示在 Android Material Buttons 中的文本旁边?