I have an Android application that use JNI. In JNI I used C++ STL library to output some data into a text file. This is the snippet code.
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include <fstream>
float mydata[4] = {0.0f};
ofstream file;
file.open("Data.txt", ios::app);
// For example
file<<mydata[1];
file.close();
when I ran ndk-build, I did not face any errors and the program seems run properly. But I did not found any text file in my Application directory. does anybody know what could be the issue? Please help.
You should check if the file is actually opened file.is_open(). There are permissions you have to request in your app settings in order to access certain features, such as if you want to access external storage devices. Also not sure where you are looking for the file or what the working directory is for an app.