我怎样写与NativeActivity的内部存储文件系统? [英] How do I write to the internal storage file system with NativeActivity?

查看:116
本文介绍了我怎样写与NativeActivity的内部存储文件系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我过到Android移植一个纯C ++游戏,因为我的目标是安卓3.0+平板电脑,我选择使用NativeActivity的,以避免完全的Java。但是,我不能看到任何功能,可以让我写到设备的内部存储。调用fopen()函数将失败,因为我不知道在哪个目录,我应该写,内部存储的文件系统是无法访问

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

这code通常不会对Java的把戏,为我的应用程序内部的可写数据目录给我的路径:

This code usually does the trick on Java, giving me the path to the internal writable data directory for my app:

mContext.getFilesDir();

有谁知道对于C替代++?否则,我会打电话给上面的代码段用JNI。

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

当然,我特地到的 $ NDK /..../包括/安卓/ 的头,但我看不出有任何候选方法我需要什么。

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

推荐答案

我终于找到了。原来的路径,内部存储目录中被声明为ANativeActivity的一员机器人/ native_activity.h

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;

这篇关于我怎样写与NativeActivity的内部存储文件系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆