Java – unable to write files in Android emulator
Problem description
I'm writing an application for Android and using native code, and testing it on the Android emulator To see what happens in the JNI code, I create a file in the Android / data / logtest / folder and write my log information in it
FILE * pFile; pFile = fopen ("/data/LogTest/Log.txt"","w"); // .... // Write some logs to file ... // ....
When I first ran the Android application, everything was normal and I could see the log Txt file But when I close the Android application and run it again, nothing happens It's like the application can't write the log to the file a second time
Self thought
I think the main reason for this problem is that when I first create a file, the creator application name is ex. 456, and then when I try to write more information to the file, the application name is for ex. therefore, application 856 cannot write to the file where application 456 has been created
topic
>How do I start an application with the same name so that Android lets me write a file a second time. > Or the main reason for the problem may not be that the application gets the rundom name every time
Solution
I don't think you can write in that folder Read the answers here Use an SDK card or application directory to store files
File Operations in Android NDK