While running the app on the emulator, system reports an error while cpp code trying to create a directory in folder "/home/cocadas/Workspace/android-project/JNIAppSample".
Java will call a JNI cpp function to create the directory.
The cpp source code is as following:
static int createEventDir(void)
{
int result;
int stringLen;
time_t currentTime = time(0);
struct tm * now = localtime(¤tTime);
stringLen = sprintf(thisEventParms.eventDirectory,
ADAN_EVENT_BASE_DIR, now->tm_mon + 1,
now->tm_mday, now->tm_hour,
now->tm_min, now->tm_sec);
if (stringLen > 0)
{
result = mkdir(thisEventParms.eventDirectory, 0700);
}
else
{
// TBD: Error, unable to make event directory
result = -1;
}
return(result);
}
Android Studio debug reports result = -1 after executing result = mkdir(thisEventParms.eventDirectory, 0700); Also, debug reports thisEventParms.eventDirectory = "/home/cocadas/Workspace/android-project/JNIAppSample", which is expected.
After some research, I add one permission in manifest like the following:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
But it still gives result = -1
Any comment or suggestion?