开发者

How do I write to the internal storage file system with NativeActivity?

I'm porting a pure C++ game over to Android, and since my target is Android 3.0+ tablets, I opted to use NativeActivity in order to avoid Java completely. However, I am not able to see any functionality that lets me write to the device's internal storage. Calls to fopen() will fail as I have no idea which directory I am supposed to write and the internal storage filesystem is not accessible

This code usually does the trick on Java, giving me the path to the internal writable data di开发者_StackOverflow社区rectory for my app:

mContext.getFilesDir();

Does anybody know an alternative for C++? Otherwise I'll have to call the snippet above with JNI.

Of course, I have looked into the $NDK/..../include/android/ headers but I see no candidate methods for what I need.


I finally found it. Turns out the path to the internal storage directory is declared as a member of ANativeActivity in android/native_activity.h:

/**
 * Path to this application's internal data directory.
 */
const char* internalDataPath;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜