Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 662
Dmitry Brant Avatar asked Mar 06 '12 02:03

Dmitry Brant


1 Answers

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

like image 67
sherpya Avatar answered Nov 20 '22 12:11

sherpya