简体   繁体   English

Android低级读取SD卡大于2GB

[英]Android low-level read of SD card greater than 2GB

My Android application attempts to read the physical sectors of the SD card by accessing the actual device (in my case, /dev/block/vold/179:1). 我的Android应用程序尝试通过访问实际设备(在我的情况下为/ dev / block / vold / 179:1)读取SD卡的物理扇区。 (this is on a rooted phone, of course) (当然,这是在有根电话的情况下)

I'm able to open the device as a FileInputStream , and read data from it. 我可以将设备作为FileInputStream打开,并从中读取数据。 However, I can't seem to read it past the 2GB mark (my memory card is 16GB). 但是,我似乎无法读取超过2GB的标记(我的存储卡为16GB)。

Is this because Android doesn't support files greater than 2GB? 这是因为Android不支持大于2GB的文件吗? If that's the case, why do functions like position() and skip() accept long arguments?? 如果是这样,为什么诸如position()skip()类的函数接受long参数?

Does anyone have advice on how to read from the device past 2GB? 是否有人对如何读取2GB以上的设备有建议?

try create with a native (jni) lib and call __llseek() 尝试使用本地(jni)库创建并调用__llseek()

int __llseek(unsigned int fd, unsigned long offset_high,
             unsigned long offset_low, loff_t *result,
             unsigned int whence);

I think you should add the prototype in your code because I doubt there is a direct include (sys/linux-unistd.h) 我认为您应该在代码中添加原型,因为我怀疑直接包含(sys / linux-unistd.h)

of course this approach is a bit undocumented :) but you can use java after android 3 and this trick before 当然,这种方法是有点未公开的:),但您可以在android 3之后使用java,而在之前使用此技巧

man _llseek for additional infos man _llseek获取更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM