I have problems creating and writing files to an Android device in Qt. I have unsuccessfully tried a few different examples.
This example should write to the internal storage's Download folder:
QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
qDebug() << path; // '/storage/emulated/0/Download'
qDebug() << "Exists? " << QFile::exists(path + "/401891.png"); // This is an existing image in the folder, returns true
QFile testFile(path.append("/Testing.txt"));
testFile.open(QFile::WriteOnly);
QTextStream out(&testFile);
out << "Hello";
testFile.close();
qDebug() << "Exists? " << QFile::exists(path + "/Testing.txt"); // Returns false
I get this warning:
Warning: QIODevice::write (QFile, "/storage/emulated/0/Download/Testing.txt"): device not open
What I am missing and how to fix it?