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

五迷三道 提交于 2019-12-12 08:41:10

问题


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)

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).

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??

Does anyone have advice on how to read from the device past 2GB?


回答1:


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);

I think you should add the prototype in your code because I doubt there is a direct include (sys/linux-unistd.h)

of course this approach is a bit undocumented :) but you can use java after android 3 and this trick before

man _llseek for additional infos



来源:https://stackoverflow.com/questions/9577098/android-low-level-read-of-sd-card-greater-than-2gb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!