I have ported a very large application to Android. It receives binary data over TCP/IP, and writes it to files which it uses now and then in the application. The directory to which it saves the files is by default set to ./file_cache. It goes wrong here:
fileHandle = fopen(filename,"wb");
filename in this case is "file_i" where i starts from 0 and increments for every file.
The program crashes on writing, and it doesn't have to crash on the first file, sometimes it gets as far as the 10th file. When it crashes the fileHandle ends up as NULL.
The filename is initially in wchar, but is converted before (I print it out in the logger to confirm that it is correct).
What I have tried:
I have added all permissions that seem to have anything to do with file read/write external storage.
I have tried different locations /sdcard/files and /data/data/<package>/files
Questions:
What is the current directory, i.e. where do the files really end up on the default setting?
What can be causing fopen to return null, which in turn is the cause of the crash?
Very thankful for any ideas.