the question sounds quite trivial, but I couldn't find an answer.
I'm porting a computer vision library to android from linux and it requires a settings file (.yaml) and a big (100mb) vocabulary file (.txt). I thought to create a folder on /sdcard/ and copy those files there. the library uses cv::FileStorage to read the file, from OpenCV. It fails with the message on logs (cerr) : " global persistence.cpp:512 open Can't open file: '/sdcard/MyFolder/Settings.yaml' in read mode".
I tried from a new C++ project, to read the file myself with the snippet:
std::string hello = "Hello from C++"; // from basic c++ project template
//ifstream in("/storage/self/primary/MyFolder/Settings.yaml");
ifstream in("/sdcard/MyFolder/Settings.yaml");
LOGI("File is %s", in.good() ? "good" : "bad");
for (int i = 0; i < 10; i++)
{
string text;
getline(in, text);
LOGI("%s", text.c_str());
}
return env->NewStringUTF(hello.c_str());
but no luck. On Log i get "file is bad" and then 10 empty lines.
I tried various combinations of permissions READ_EXTERNAL_STORAGE, READ_MEDIA_AUDIO, READ_MEDIA_IMAGES, READ_MEDIA_VIDEO and to ask permissions at runtime after migrating to AndroidX.
I actually have no idea if I can even use the filesystem at this point.
Where can I store a configuration file so an user (of the prototype) can upload their settings and the lib can read it through OpenCV FileStorage and what other steps are necessary? (Permissions, etc.)
Probably related:
https://stackoverflow.com/questions/75934748/read-write-file-with-ndk-always-gives-me-errno-13-permission-denied