来自 NDK 的 GetFilesDir()? [英] GetFilesDir() from NDK?
问题描述
有没有办法直接从 NDK 获取应用程序的目录以将私有数据保存到我的应用程序的文件中?换句话说,我需要一个等效的 Java 函数 mContext.getFilesDir().
Is there a way to get the application's directory to save private data to a file for my application directly from the NDK? In other words, I need an equivalent of the Java function mContext.getFilesDir().
我注意到其他帖子,例如这个:Android NDK 写入文件
I have noted that other posts such as this one: Android NDK Write File
提及该目录的通常"位置是什么.但要使其在所有版本和所有设备中都正确,肯定需要等效的系统调用.
mention what is the 'usual' place for this directory to be. But for it to be correct in all versions and all devices, an equivalent system call is surely necessary.
我目前使用的是 NativeActivity,根本没有使用 Java.
I am currently using a NativeActivity and no Java at all.
感谢您的宝贵时间.
推荐答案
如果您使用的是 NativeActivity
,那么您可以从本地代码访问 ANativeActivity
实例(请参阅 <ndk_root>/platforms/android-9/arch-arm/usr/include/android/native_activity.h
) 具有 internalDataPath
和 externalDataPath
成员.
If you are using NativeActivity
then you have access from native code to an ANativeActivity
instance (see <ndk_root>/platforms/android-9/arch-arm/usr/include/android/native_activity.h
) which has internalDataPath
and externalDataPath
members.
这篇关于来自 NDK 的 GetFilesDir()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!