为什么FOPEN获取本地方法失败归因于来自Android的NDK应用程序权限问题? [英] Why fopen gets fail in native method due to permission issue from Android-NDK application?
问题描述
我看到下面有一个本地调用code
see i have following code in one native call
errno = 0;
FILE *fp;
fp = fopen("jigar.txt","wb");
if(fp == NULL)
__android_log_print(ANDROID_LOG_ERROR, APPNAME, "FOPEN FAIL with %d",errno);
else
__android_log_print(ANDROID_LOG_ERROR, APPNAME, "FOPEN pass ");
它得到失败,并显示
which gets fail and shows
FOPEN FAIL with 30
现在这里30意味着它会显示错误
now here 30 means it shows error
#define EROFS 30 /* Read-only file system */
在我的应用程序MainFest文件我已经加入这一行
In MainFest file on my application i have added this line
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
还我收到此错误。
still i am getting this error..
如何解决这个问题?
修改
由于通过指定文件夹的名称它的工作原理但
thanks by specifies folder name it works But
在我的情况我有有这样的fopen一个库()调用,其中文件名我不能给。这需要它默认的文件名。
In my case i have one Library which has such fopen() call where file names i can not give. It takes it default filename.
,我用我的NDK应用该库中,以便在这种情况下,如何解决呢?
And i am using this Library in my ndk application so in this case how to solve this?
推荐答案
yuppi最后我得到了
yuppi finally i got that
我有没有这样
首先从/
改变我的进程的当前目录/ SD卡/
first change the current directory of my process from "/"
to "/sdcard/"
chdir("/sdcard/");
,然后找到关于路径/ SD卡/
and then it find path with respect to /sdcard/
和一切工作正常.. !!!
and everything WORKING..!!!
这篇关于为什么FOPEN获取本地方法失败归因于来自Android的NDK应用程序权限问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!