Android read text file from asset folder using C (ndk)

前端 未结 3 1333
广开言路
广开言路 2020-12-01 11:14

I need to read text file from asset folder in android, by searching through internet I found that there is asset_manager api available from android 2.3 onwards. As I am targ

3条回答
  •  一整个雨季
    2020-12-01 12:10

    It's pretty similar to regular fread/fseek functions. Here's read function declaraton:

    ssize_t read(int fd, void *buf, size_t count);
    

    It reads from fd file descriptor into buf buffer count bytes. If you think about fread, then instead of:

    fread(buf, count, size, file);
    

    you will call:

    read(fd, buf, count*size);
    

    And that's it. It is so simple.

    Seeking is also similar. Just look up the function declaration and read the argument names/description. It will be obvious.

提交回复
热议问题