GetFilesDir()从NDK?GetFilesDir、NDK

2023-09-12 10:30:43 作者:zんιゐ聹情Ψ

有没有一种方法来获取应用程序的目录私人数据保存到一个文件,我从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().

我注意到其他职位像这样的: 的Andr​​oid 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的,那么你必须从本地code访问一个ANativeActivity实例(见/平台/ Android的9 /弓臂的/ 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 /platforms/android-9/arch-arm/usr/include/android/native_activity.h) which has internalDataPath and externalDataPath members.