5

I am trying to create an input stream from a text file stored in my assets folder in the android project, but I'm having some trouble. Is it sufficient to just provide the path to the file as you would in a regular desktop program (using ifstream file_handle; file_handle.open("path/to/fileName");), or do you have to somehow load it onto the application in another way? If it's the latter, what is the code for doing that in the ndk? Would I still be able to use the file as an ifstream object?

Thanks,

naxchange

naxchange
  • 893
  • 1
  • 11
  • 24
  • [read this](https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/8OUuRjWSHLI) IMHO you better access resources from java. – Leonidos Feb 20 '13 at 13:49

1 Answers1

5

Android assets are packed in apk's, so you can't access them directly with streams or file handles.

You need to use Native Asset Manager API / AAssetManager to be able to read them. Look up in asset_manager.h in $NDK/platforms/.. to see about possible functions on how to access your assets from native.

You may want to check a similar question / answer .

Community
  • 1
  • 1
auselen
  • 27,577
  • 7
  • 73
  • 114