I have Java Android application (TestApp). From my TestApp I call function from jni code:
JNIEXPORT jint JNICALL Java_com_app_test_testApp_CreateFile( JNIEnv* env, jobject thiz, jobject jclass ) {
pFile = fopen ("/NDK_Log.txt", "a+");
// Get's current date time and print it in the log file.
dateTime = time(NULL);
currentTime = ctime( &dateTime );
fprintf( pFile, "\n\n--------------------------------------------------------------------------\n" );
fprintf( pFile, "\t\t\t\t\t\t %s", currentTime );
fprintf( pFile, "--------------------------------------------------------------------------\n\n" );
fprintf( pFile, ">>> Enter Initialize <<<\n" );
#endif
return 0;
}
I want to create file in “data/data/com.app.test.testApp/” folder but I can’t, what I am doing wrong, and how I can specify current working directory or give current path of application ?
You can’t rely on fopen to use “current working directory”.
In device internal memory, you can access only files in your app’s data folder.
And you may get your app’s private folder this way:
It will be somewhere in /data/data folder.