问题描述
我移植到Android。我现有的项目有一吨是我移植到我的Android项目的资源文件。我把它们都在/ RES /生/,我想访问这些资源在我的本地库函数,如fopen()和等。可以这样做,还是我必须去通过JNI这个呢?我真的preFER不,为便于移植和可能的速度和内存的原因。
I'm porting to Android. My existing project has a ton of resource files that I'm porting into my Android project. I have them all in /res/raw/, and I would like to access those resources in my native library with functions such as fopen() and such. Can this be done, or do I have to go through JNI for this as well? I would really prefer not to, for ease of porting and possible speed and memory reasons.
推荐答案
如果您 $ P $因为它们添加到您的APK那么你就可以 pvent您的资产href="http://groups.google.com/group/android-ndk/browse_thread/thread/a69084018e87a5a8/9c513f8eb2956b87">use openRawResourceFd()来获得一个文件描述符,偏移和大小并传递给你的本地code,你只是做一个的fopen和fseek的。在另一方面,如果你让构建系统融为一体preSS要访问这些文件,你需要使用像 libzip 从APK阅读。
这篇关于读取资源文件从Android原生环境我自己的APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!