Android低级读取SD卡大于2GB [英] Android low-level read of SD card greater than 2GB
问题描述
我的Android应用程序尝试通过访问实际设备(在我的情况下为/dev/block/vold/179:1)读取SD卡的物理扇区.(当然,这是在有根电话的情况下)
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). (this is on a rooted phone, of course)
我能够以 FileInputStream
的形式打开设备,并从中读取数据.但是,我似乎无法读取超过2GB的标记(我的存储卡为16GB).
I'm able to open the device as a FileInputStream
, and read data from it. However, I can't seem to read it past the 2GB mark (my memory card is 16GB).
这是因为Android不支持大于2GB的文件吗?如果是这种情况,为什么 position()
和 skip()
之类的函数会接受 long
个参数?
Is this because Android doesn't support files greater than 2GB? If that's the case, why do functions like position()
and skip()
accept long
arguments??
有人对从2GB以上的设备中读取数据有任何建议吗?
Does anyone have advice on how to read from the device past 2GB?
推荐答案
尝试使用本地(jni)库创建并调用__llseek()
try create with a native (jni) lib and call __llseek()
int __llseek(unsigned int fd, unsigned long offset_high,
unsigned long offset_low, loff_t *result,
unsigned int whence);
我认为您应该在代码中添加原型,因为我怀疑直接包含(sys/linux-unistd.h)
I think you should add the prototype in your code because I doubt there is a direct include (sys/linux-unistd.h)
当然,这种方法有点没有记载:),但是您可以在android 3之后使用Java,而在此之前使用此技巧
of course this approach is a bit undocumented :) but you can use java after android 3 and this trick before
man _llseek
了解更多信息
这篇关于Android低级读取SD卡大于2GB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!