I'm developing a native library for Android and I need to write/read some temporary files. As it's library I don't know in what context it will be used later.
Searching on SO I've found out that data/data/<Your_package_name_usually com.android.appName>/files/
is a good place to put write/read files, but I don't know how to get package name using NDK and it seems this is not valid in all conditions(Android NDK Write File)
Other solution would be to use internalDataPath
from ANativeActivity
, but I don't know how to obtain a valid ANativeActivity
object from the library(GetFilesDir() from NDK?)
Is there any safe place put temporary files on Android using C++?
Please forgive me if I write some dumb things here, I'm new to Android development. Thank you!
EDIT: As a design requirement I'm not allowed to use Java/JNI calls.