Hello,
I've been trying to copy some assets to external storage in my Java code, and pass the directory to my native code to read from. However, the problem is, if there is no SD card on the device the getExternalFilesDir() returns something like "storage/emulated/0/Android/data/<my_app>/files", which when I pass to the native code to fopen and fread, causes the app to crash. I believe the reason is because the directory is artificial or a symbolic link or something of the sort. However, even if I use the stdlib.h function realpath() on the path passed down to the native code, it still crashes. If however, I manually replace emulated/0/ with emulated/legacy/ in the path, realpath() suddenly works and converts it to the actual location the files are stored, and the fread() works fine with no crashes.
The problem is I want to write code that is reliable in the long run, regardless of changes to the way Android organizes external storage and these symbolic links/virtual filesystems. I also want the code to work regardless of which device it is run on (I believe these emulated directories are different depending on the device).
Is this an oversight in the design of these virtual filesystems? Is there some way to get an external storage directory in Java that can be written to and reliably read from in native code as well?
Thank you for any help you can give me.