Created
April 19, 2021 13:45
-
-
Save LGLTeam/9ba745b7d25965956580d63624f6937b to your computer and use it in GitHub Desktop.
Reading and writing text file via c++ for Android. No root
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <cstring> | |
#include <fstream> | |
#include <iostream> | |
std::string dir = "/data/data/uk.lgl.modmenu/cache/imei"; | |
std::string buf = "whatever"; | |
std::ifstream myfile(dir); | |
if (!myfile.is_open()) { | |
std::ofstream os(dir.c_str(), std::ios::trunc); | |
os.write(buf.c_str(), buf.length()); | |
os.close(); | |
} | |
std::ifstream getfile("/data/data/uk.lgl.modmenu/cache/imei"); | |
std::string line; | |
if (myfile.is_open()) | |
{ | |
while (getline (getfile,line) ) | |
{ | |
std::cout << line << '\n'; | |
} | |
myfile.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment