Skip to Main Content
Android NDK Beginner`s Guide - Second Edition
book

Android NDK Beginner`s Guide - Second Edition

by Sylvain Ratabouil
April 2015
Beginner to intermediate content levelBeginner to intermediate
494 pages
10h 26m
English
Packt Publishing
Content preview from Android NDK Beginner`s Guide - Second Edition

Time for action – read files with STL stream

Let's use the STL to read resources from the SD card instead of the application asset directory, as shown in the following steps:

  1. Obviously, enabling the STL is useless if we do not actively use it in our code. Let's take advantage of this opportunity to switch from asset files to external files (on a sdcard or internal memory).

    Open the existing file, jni/Resource.hpp, and do the following:

    • Include the fstream and string STL headers.
    • Use a std::string object for the file name and replace the Asset management members with an std::ifstream object (that is, an input file stream).
    • Change the getPath() method to return a C string from the new string member.
    • Remove the descriptor() method and the ResourceDescriptor ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro Android C++ with the NDK

Pro Android C++ with the NDK

Onur Cinar
Learning Embedded Android N Programming

Learning Embedded Android N Programming

Ivan Morgillo, Stefano Viola

Publisher Resources

ISBN: 9781783989645Supplemental Content