Access resource Files in C++

Put problems with the Android NDK in this forum.

Access resource Files in C++

Postby LukasBanana » Sun Aug 07, 2011 12:24 pm

Hi Folks,
Is it possible to access the resouce files with the NDK in C/C++?
I would like to use the ANSI-C FILE functions ("fopen", "fwrite" etc.).

In Java I read resource files as follows:

Code: Select all
InputStream stream = Context.getResources().openRawResource(int ResourceID)

try {
   final int size = stream.available();
   
   ByteBuffer buffer = ByteBuffer.allocateDirect(size);
   buffer.order(ByteOrder.nativeOrder());
   
   byte[] streamBuffer = new byte[size];
   
   stream.read(streamBuffer);
   stream.close();
   
   buffer.put(streamBuffer);
   buffer.position(0);
   
   return true;
} catch (IOException e) {
   Log.e(TAG, "Could not read raw resource");
   e.printStackTrace();
}


BTW: there is somewhere a good NDK API documentation? I can only find the Java docs
LukasBanana
Freshman
Freshman
 
Posts: 7
Joined: Tue Mar 08, 2011 9:01 pm

Top

Return to NDK Problems

Who is online

Users browsing this forum: No registered users and 3 guests