use freopen to redirect stdout and stderr
the native code below works for me.
// cachedir is get from java code 'Context.getExternalCacheDir().getAbsolutePath()' auto fullpath = cachedir + "/log"; freopen(fullpath.c_str(),"w",stderr); std::cerr << "hello, world\n"; // will write to file located at external storage
source share